Example of usage use Bluz\Proxy\Registry; Registry::set('key', 'value'); Registry::get('key');
또한 보기: Instance::set()
또한 보기: Instance::get()
또한 보기: Instance::contains()
또한 보기: Instance::delete()
저자: Anton Shevchuk
상속: use trait ProxyTrait
예제 #1
0
<?php

/**
 * Bluz Framework Component
 *
 * @copyright Bluz PHP Team
 * @link https://github.com/bluzphp/framework
 */
/**
 * @namespace
 */
namespace Bluz\Layout\Helper;

use Bluz\Layout\Layout;
use Bluz\Proxy\Registry;
return function ($script = null) {
    // it's stack for <head>
    $headScripts = Registry::get('layout:headScripts') ?: [];
    if (null === $script) {
        $headScripts = array_unique($headScripts);
        // clear system vars
        Registry::set('layout:headScripts', []);
        $headScripts = array_map([$this, 'script'], $headScripts);
        return join("\n", $headScripts);
    } else {
        $headScripts[] = $script;
        Registry::set('layout:headScripts', $headScripts);
        return null;
    }
};
예제 #2
0
<?php

/**
 * Bluz Framework Component
 *
 * @copyright Bluz PHP Team
 * @link https://github.com/bluzphp/framework
 */
/**
 * @namespace
 */
namespace Bluz\Layout\Helper;

use Bluz\Layout\Layout;
use Bluz\Proxy\Registry;
return function (array $data = []) {
    if (sizeof($data)) {
        Registry::set('layout:breadcrumbs', $data);
        return null;
    } else {
        return Registry::get('layout:breadcrumbs');
    }
};
예제 #3
0
파일: Title.php 프로젝트: 9618211/framework
 */
/**
 * @namespace
 */
namespace Bluz\Layout\Helper;

use Bluz\Layout\Layout;
use Bluz\Proxy\Registry;
return function ($title = null, $position = Layout::POS_REPLACE, $separator = ' :: ') {
    // it's stack for <title> tag
    if (null === $title) {
        return Registry::get('layout:title');
    } else {
        $oldTitle = Registry::get('layout:title');
        // switch statement for text position
        switch ($position) {
            case Layout::POS_PREPEND:
                $result = $title . (!$oldTitle ?: $separator . $oldTitle);
                break;
            case Layout::POS_APPEND:
                $result = (!$oldTitle ?: $oldTitle . $separator) . $title;
                break;
            case Layout::POS_REPLACE:
            default:
                $result = $title;
                break;
        }
        Registry::set('layout:title', $result);
        return null;
    }
};
예제 #4
0
 /**
  * Test Registry configuration setup
  */
 public function testRegistry()
 {
     $this->assertEquals(["moo" => "baz"], Proxy\Config::getData("registry"));
     $this->assertEquals("baz", Proxy\Config::getData("registry", "moo"));
     $this->assertEquals("baz", Proxy\Registry::get('moo'));
 }
예제 #5
0
파일: Meta.php 프로젝트: 9618211/framework
use Bluz\Layout\Layout;
use Bluz\Proxy\Registry;
return function ($name = null, $content = null) {
    // it's stack for <head>
    $meta = Registry::get('layout:meta') ?: [];
    if ($name !== null && $content !== null) {
        $meta[] = ['name' => $name, 'content' => $content];
        Registry::set('layout:meta', $meta);
        return null;
    } elseif (is_array($name)) {
        $meta[] = $name;
        Registry::set('layout:meta', $meta);
        return null;
    } elseif (is_null($name) && is_null($content)) {
        if (sizeof($meta)) {
            // prepare to output
            $meta = array_map(function ($attr) {
                return '<meta ' . $this->attributes($attr) . '/>';
            }, $meta);
            // clear system vars
            Registry::set('layout:meta', []);
            return join("\n", $meta);
        } else {
            return '';
        }
    } else {
        // if exists only $name or $content
        return null;
    }
};
예제 #6
0
<?php

/**
 * Bluz Framework Component
 *
 * @copyright Bluz PHP Team
 * @link https://github.com/bluzphp/framework
 */
/**
 * @namespace
 */
namespace Bluz\Layout\Helper;

use Bluz\Layout\Layout;
use Bluz\Proxy\Registry;
return function ($style = null, $media = 'all') {
    // it's stack for <head>
    $headStyle = Registry::get('layout:headStyle') ?: [];
    if (null === $style) {
        // clear system vars
        Registry::set('layout:headStyle', []);
        array_walk($headStyle, function (&$item, $key) {
            $item = $this->style($key, $item);
        });
        return join("\n", $headStyle);
    } else {
        $headStyle[$style] = $media;
        Registry::set('layout:headStyle', $headStyle);
        return null;
    }
};
예제 #7
0
파일: Link.php 프로젝트: 9618211/framework
/**
 * Bluz Framework Component
 *
 * @copyright Bluz PHP Team
 * @link https://github.com/bluzphp/framework
 */
/**
 * @namespace
 */
namespace Bluz\View\Helper;

use Bluz\Layout\Layout;
use Bluz\Proxy\Registry;
return function (array $link = null) {
    // it's stack for <head>
    $links = Registry::get('layout:link') ?: [];
    if (is_null($link)) {
        // prepare to output
        $links = array_map(function ($attr) {
            return '<link ' . $this->attributes($attr) . '/>';
        }, $links);
        // clear system vars
        Registry::set('layout:link', []);
        $links = array_unique($links);
        return join("\n", $links);
    } else {
        $links[] = $link;
        Registry::set('layout:link', $links);
        return null;
    }
};