Class luya\testsuite\components\DummyMenu

Inheritanceluya\testsuite\components\DummyMenu » luya\cms\Menu » yii\base\Component » yii\base\BaseObject
ImplementsArrayAccess, luya\cms\menu\QueryOperatorFieldInterface, yii\base\Configurable
Uses Traitsluya\testsuite\traits\CmsDatabaseTableTrait, luya\traits\CacheableTrait
Available since version1.0.31
Source Code https://github.com/luyadev/luya-testsuite/blob/master/src/components/DummyMenu.php

LUYA CMS Dummy Menu Component.

A Component to create dummy menus using $items property for each language.

Public Properties

Hide inherited properties

Property Type Description Defined By
$behaviors yii\base\Behavior[] List of behaviors attached to this component. yii\base\Component
$composition luya\web\Composition Get the composition. luya\cms\Menu
$current luya\cms\menu\Item Get the current active menu item. luya\cms\Menu
$currentAppendix string The url part not related for the current active link luya\cms\Menu
$currentUrlRule array Get the url rules for the current menu item. luya\cms\Menu
$encoding boolean Whether all menu item text values should be html encoded or not, since version 1.0.7.2 this is enabled by default in order to ensure administrators can not inject xss code into frontend. luya\cms\Menu
$home luya\cms\menu\Item Get the home menu item. luya\cms\Menu
$items array An array with items for each language. luya\testsuite\components\DummyMenu
$languages array An array where the key is the short_code and the value an array containing shortcode and id. luya\cms\Menu
$modulesMap array An array with all modules index by the id luya\cms\Menu
$redirectMap array An array where the key is the id and the value an array containing id, type and value. luya\cms\Menu
$request luya\web\Request Request object luya\cms\Menu

Public Methods

Hide inherited methods

Method Description Defined By
__call() Calls the named method which is not a class method. yii\base\Component
__clone() This method is called after the object is created by cloning an existing one. yii\base\Component
__construct() Class constructor to DI the request object. luya\cms\Menu
__get() Returns the value of a component property. yii\base\Component
__isset() Checks if a property is set, i.e. defined and not null. yii\base\Component
__set() Sets the value of a component property. yii\base\Component
__unset() Sets a component property to be null. yii\base\Component
attachBehavior() Attaches a behavior to this component. yii\base\Component
attachBehaviors() Attaches a list of behaviors to the component. yii\base\Component
behaviors() Returns a list of behaviors that this component should behave as. yii\base\Component
buildItemLink() Prepand the base url for the provided alias. luya\cms\Menu
canGetProperty() Returns a value indicating whether a property can be read. yii\base\Component
canSetProperty() Returns a value indicating whether a property can be set. yii\base\Component
className() Returns the fully qualified name of this class. yii\base\BaseObject
createCmsBlockFixture() Create Cms Block Fixture luya\testsuite\traits\CmsDatabaseTableTrait
createCmsBlockGroupFixture() Create Cms Block Group Fixture luya\testsuite\traits\CmsDatabaseTableTrait
createCmsLayoutFixture() Create Cms Layout Fixture luya\testsuite\traits\CmsDatabaseTableTrait
createCmsLog() Create Cms Log Fixture luya\testsuite\traits\CmsDatabaseTableTrait
createCmsNavContainerFixture() Create Cms Nav Container Fixture luya\testsuite\traits\CmsDatabaseTableTrait
createCmsNavFixture() Create Cms Nav Fixture luya\testsuite\traits\CmsDatabaseTableTrait
createCmsNavItemFixture() Create Cms Nav Item Fixture luya\testsuite\traits\CmsDatabaseTableTrait
createCmsNavItemModuleFixture() Create Cms Nav Item Module Fixture luya\testsuite\traits\CmsDatabaseTableTrait
createCmsNavItemPageBlockItemFixture() Create Cms Nav Item Page Block Item Fixture luya\testsuite\traits\CmsDatabaseTableTrait
createCmsNavItemPageFixture() Create Cms Nav Item Page Fixture luya\testsuite\traits\CmsDatabaseTableTrait
createCmsNavItemRedirectFixture() Create Cms Nav Item Redirect Fixture luya\testsuite\traits\CmsDatabaseTableTrait
createCmsNavPermissionFixture() Create Cms Nav Permissions Fixture luya\testsuite\traits\CmsDatabaseTableTrait
createCmsPropertyFixture() Create Cms Property Fixture luya\testsuite\traits\CmsDatabaseTableTrait
createCmsRedirectFixture() Create Cms Redirect Fixture luya\testsuite\traits\CmsDatabaseTableTrait
createCmsWebsiteFixture() Create Cms Website Fixture luya\testsuite\traits\CmsDatabaseTableTrait
deleteHasCache() Remove a value from the cache if caching is enabled. luya\traits\CacheableTrait
detachBehavior() Detaches a behavior from the component. yii\base\Component
detachBehaviors() Detaches all behaviors from the component. yii\base\Component
encodeValue() Determines and encodes the given value if enabled. luya\cms\Menu
ensureBehaviors() Makes sure that the behaviors declared in behaviors() are attached to this component. yii\base\Component
find() Wrapper method for new \luya\cms\menu\Query() object. luya\cms\Menu
findAll() Wrapper method to get all menu items for the current language without hidden items for the specific where statement. luya\cms\Menu
findOne() Wrapper method to get one menu item for current language without hidden items for the sepcific where statement. luya\cms\Menu
flushCache() Flush all caching data for the menu for each language luya\cms\Menu
flushHasCache() Deletes all values from cache. luya\traits\CacheableTrait
getBehavior() Returns the named behavior object. yii\base\Component
getBehaviors() Returns all behaviors attached to this component. yii\base\Component
getComposition() Get the composition component if not yet loaded. luya\cms\Menu
getCurrent() Get the current menu item resolved by active language (from composition). luya\cms\Menu
getCurrentAppendix() Returns the parts of the rules who do not belong to the current active menu item link. luya\cms\Menu
getCurrentUrlRule() Get the url rules for the current menu item. luya\cms\Menu
getHasCache() Get the caching data if caching is allowed and there is any data stored for this key. luya\traits\CacheableTrait
getHome() Return the home site for the current resolved language resolved by {{luya\web\Composition}} component. luya\cms\Menu
getLanguage() Get languag information for a specific language short code. luya\cms\Menu
getLanguageContainer() Load and return the language container for the specific langShortCode, this method is used when using the ArrayAccess offsetGet() method. luya\cms\Menu
getLanguages() Get an array with all available system languages based on the admin_lang table. luya\cms\Menu
getLevelContainer() Get all items for a specific level. luya\cms\Menu
getLevelCurrent() Get the current item for specified level/depth. Menus always start on level/depth 1. This works only in reversed order, to get the parent level from a child! luya\cms\Menu
getModulesMap() Return all nav item modules to request data later in items luya\cms\Menu
getOrSetHasCache() Method combines both setHasCache() and getHasCache() methods to retrieve value identified by a $key, or to store the result of $closure execution if there is no cache available for the $key. luya\traits\CacheableTrait
getRedirectMap() Get an array containing all redirect items from the database table cms_nav_item_redirect. luya\cms\Menu
hasEventHandlers() Returns a value indicating whether there is any handler attached to the named event. yii\base\Component
hasMethod() Returns a value indicating whether a method is defined. yii\base\Component
hasProperty() Returns a value indicating whether a property is defined for this component. yii\base\Component
init() Initializes the object. luya\testsuite\components\DummyMenu
injectItem() luya\cms\Menu
isCachable() Check if the current configuration of the application and the property allows a caching of the language container data. luya\traits\CacheableTrait
off() Detaches an existing event handler from this component. yii\base\Component
offsetExists() ArrayAccess check if the offset key exists in the language array. luya\cms\Menu
offsetGet() ArrayAccess get the current offset key if not yet loaded. luya\cms\Menu
offsetSet() ArrayAccess offsetSet is not implemented in singleton component. luya\cms\Menu
offsetUnset() ArrayAccess offsetSet is not implemented in singleton component. luya\cms\Menu
on() Attaches an event handler to an event. yii\base\Component
setCurrent() Ability to override the current item in order to make real preview urls (as when resolver does not work of changed urls). luya\cms\Menu
setCurrentUrlRule() Set url rules for the current page item in order to retrieve at another point of the appliation when building language links. luya\cms\Menu
setHasCache() Store cache data for a specific key if caching is enabled in this application. luya\traits\CacheableTrait
setLanguageContainer() Setter method for the language container. luya\cms\Menu
trigger() Triggers an event. yii\base\Component

Protected Methods

Hide inherited methods

Method Description Defined By
itemToStructure() Generate Menu structure for item. luya\testsuite\components\DummyMenu
normalizeItems() Generate a flat menu structure from items. luya\testsuite\components\DummyMenu

Constants

Hide inherited constants

Constant Value Description Defined By
EVENT_AFTER_LOAD 'eventAfterLoad' luya\cms\Menu
EVENT_AFTER_RESOLVE_CURRENT 'eventAfterResolveCurrent' luya\cms\Menu
EVENT_ON_ITEM_FIND 'eventOnItemFind' luya\cms\Menu
ITEM_TYPE_MODULE 2 luya\cms\Menu
ITEM_TYPE_PAGE 1 luya\cms\Menu
ITEM_TYPE_REDIRECT 3 luya\cms\Menu

Property Details

Hide inherited properties

$items public property

An array with items for each language.

'items' => [
    'de' => [
         1 => 'Hello',
         2 => 'World',
    ]
],

or with more specific infos:

'items' => [

'de' => [
     [
         'id' => 1,
         'title' => 'Hello',
         'is_home' => 1,
         'items' => [
             [
                 'id' => 2,
                 'title' => 'World',
                 'link' => 'hello-world-link',
             ]
         ]
     ],
],

], `

public array $items = []

Method Details

Hide inherited methods

__call() public method

Defined in: yii\base\Component::__call()

Calls the named method which is not a class method.

This method will check if any attached behavior has the named method and will execute it if available.

Do not call this method directly as it is a PHP magic method that will be implicitly called when an unknown method is being invoked.

public mixed __call ( $name, $params )
$name string

The method name

$params array

Method parameters

return mixed

The method return value

throws yii\base\UnknownMethodException

when calling unknown method

                public function __call($name, $params)
{
    $this->ensureBehaviors();
    foreach ($this->_behaviors as $object) {
        if ($object->hasMethod($name)) {
            return call_user_func_array([$object, $name], $params);
        }
    }
    throw new UnknownMethodException('Calling unknown method: ' . get_class($this) . "::$name()");
}

            
__clone() public method

Defined in: yii\base\Component::__clone()

This method is called after the object is created by cloning an existing one.

It removes all behaviors because they are attached to the old object.

public void __clone ( )

                public function __clone()
{
    $this->_events = [];
    $this->_eventWildcards = [];
    $this->_behaviors = null;
}

            
__construct() public method

Defined in: luya\cms\Menu::__construct()

Class constructor to DI the request object.

public void __construct ( luya\web\Request $request, array $config = [] )
$request luya\web\Request

The request object resolved by DI.

$config array

                public function __construct(\luya\web\Request $request, array $config = [])
{
    $this->request = $request;
    parent::__construct($config);
}

            
__get() public method

Defined in: yii\base\Component::__get()

Returns the value of a component property.

This method will check in the following order and act accordingly:

  • a property defined by a getter: return the getter result
  • a property of a behavior: return the behavior property value

Do not call this method directly as it is a PHP magic method that will be implicitly called when executing $value = $component->property;.

See also __set().

public mixed __get ( $name )
$name string

The property name

return mixed

The property value or the value of a behavior's property

throws yii\base\UnknownPropertyException

if the property is not defined

throws yii\base\InvalidCallException

if the property is write-only.

                public function __get($name)
{
    $getter = 'get' . $name;
    if (method_exists($this, $getter)) {
        // read property, e.g. getName()
        return $this->$getter();
    }
    // behavior property
    $this->ensureBehaviors();
    foreach ($this->_behaviors as $behavior) {
        if ($behavior->canGetProperty($name)) {
            return $behavior->$name;
        }
    }
    if (method_exists($this, 'set' . $name)) {
        throw new InvalidCallException('Getting write-only property: ' . get_class($this) . '::' . $name);
    }
    throw new UnknownPropertyException('Getting unknown property: ' . get_class($this) . '::' . $name);
}

            
__isset() public method

Defined in: yii\base\Component::__isset()

Checks if a property is set, i.e. defined and not null.

This method will check in the following order and act accordingly:

  • a property defined by a setter: return whether the property is set
  • a property of a behavior: return whether the property is set
  • return false for non existing properties

Do not call this method directly as it is a PHP magic method that will be implicitly called when executing isset($component->property).

See also https://www.php.net/manual/en/function.isset.php.

public boolean __isset ( $name )
$name string

The property name or the event name

return boolean

Whether the named property is set

                public function __isset($name)
{
    $getter = 'get' . $name;
    if (method_exists($this, $getter)) {
        return $this->$getter() !== null;
    }
    // behavior property
    $this->ensureBehaviors();
    foreach ($this->_behaviors as $behavior) {
        if ($behavior->canGetProperty($name)) {
            return $behavior->$name !== null;
        }
    }
    return false;
}

            
__set() public method

Defined in: yii\base\Component::__set()

Sets the value of a component property.

This method will check in the following order and act accordingly:

  • a property defined by a setter: set the property value
  • an event in the format of "on xyz": attach the handler to the event "xyz"
  • a behavior in the format of "as xyz": attach the behavior named as "xyz"
  • a property of a behavior: set the behavior property value

Do not call this method directly as it is a PHP magic method that will be implicitly called when executing $component->property = $value;.

See also __get().

public void __set ( $name, $value )
$name string

The property name or the event name

$value mixed

The property value

throws yii\base\UnknownPropertyException

if the property is not defined

throws yii\base\InvalidCallException

if the property is read-only.

                public function __set($name, $value)
{
    $setter = 'set' . $name;
    if (method_exists($this, $setter)) {
        // set property
        $this->$setter($value);
        return;
    } elseif (strncmp($name, 'on ', 3) === 0) {
        // on event: attach event handler
        $this->on(trim(substr($name, 3)), $value);
        return;
    } elseif (strncmp($name, 'as ', 3) === 0) {
        // as behavior: attach behavior
        $name = trim(substr($name, 3));
        $this->attachBehavior($name, $value instanceof Behavior ? $value : Yii::createObject($value));
        return;
    }
    // behavior property
    $this->ensureBehaviors();
    foreach ($this->_behaviors as $behavior) {
        if ($behavior->canSetProperty($name)) {
            $behavior->$name = $value;
            return;
        }
    }
    if (method_exists($this, 'get' . $name)) {
        throw new InvalidCallException('Setting read-only property: ' . get_class($this) . '::' . $name);
    }
    throw new UnknownPropertyException('Setting unknown property: ' . get_class($this) . '::' . $name);
}

            
__unset() public method

Defined in: yii\base\Component::__unset()

Sets a component property to be null.

This method will check in the following order and act accordingly:

  • a property defined by a setter: set the property value to be null
  • a property of a behavior: set the property value to be null

Do not call this method directly as it is a PHP magic method that will be implicitly called when executing unset($component->property).

See also https://www.php.net/manual/en/function.unset.php.

public void __unset ( $name )
$name string

The property name

throws yii\base\InvalidCallException

if the property is read only.

                public function __unset($name)
{
    $setter = 'set' . $name;
    if (method_exists($this, $setter)) {
        $this->$setter(null);
        return;
    }
    // behavior property
    $this->ensureBehaviors();
    foreach ($this->_behaviors as $behavior) {
        if ($behavior->canSetProperty($name)) {
            $behavior->$name = null;
            return;
        }
    }
    throw new InvalidCallException('Unsetting an unknown or read-only property: ' . get_class($this) . '::' . $name);
}

            
attachBehavior() public method

Defined in: yii\base\Component::attachBehavior()

Attaches a behavior to this component.

This method will create the behavior object based on the given configuration. After that, the behavior object will be attached to this component by calling the yii\base\Behavior::attach() method.

See also detachBehavior().

public yii\base\Behavior attachBehavior ( $name, $behavior )
$name string

The name of the behavior.

$behavior string|array|yii\base\Behavior

The behavior configuration. This can be one of the following:

return yii\base\Behavior

The behavior object

                public function attachBehavior($name, $behavior)
{
    $this->ensureBehaviors();
    return $this->attachBehaviorInternal($name, $behavior);
}

            
attachBehaviors() public method

Defined in: yii\base\Component::attachBehaviors()

Attaches a list of behaviors to the component.

Each behavior is indexed by its name and should be a yii\base\Behavior object, a string specifying the behavior class, or an configuration array for creating the behavior.

See also attachBehavior().

public void attachBehaviors ( $behaviors )
$behaviors array

List of behaviors to be attached to the component

                public function attachBehaviors($behaviors)
{
    $this->ensureBehaviors();
    foreach ($behaviors as $name => $behavior) {
        $this->attachBehaviorInternal($name, $behavior);
    }
}

            
behaviors() public method

Defined in: yii\base\Component::behaviors()

Returns a list of behaviors that this component should behave as.

Child classes may override this method to specify the behaviors they want to behave as.

The return value of this method should be an array of behavior objects or configurations indexed by behavior names. A behavior configuration can be either a string specifying the behavior class or an array of the following structure:

'behaviorName' => [
    'class' => 'BehaviorClass',
    'property1' => 'value1',
    'property2' => 'value2',
]

Note that a behavior class must extend from yii\base\Behavior. Behaviors can be attached using a name or anonymously. When a name is used as the array key, using this name, the behavior can later be retrieved using getBehavior() or be detached using detachBehavior(). Anonymous behaviors can not be retrieved or detached.

Behaviors declared in this method will be attached to the component automatically (on demand).

public array behaviors ( )
return array

The behavior configurations.

                public function behaviors()
{
    return [];
}

            
buildItemLink() public method

Defined in: luya\cms\Menu::buildItemLink()

Prepand the base url for the provided alias.

public string buildItemLink ( $alias, $langShortCode )
$alias string
$langShortCode

canGetProperty() public method

Defined in: yii\base\Component::canGetProperty()

Returns a value indicating whether a property can be read.

A property can be read if:

  • the class has a getter method associated with the specified name (in this case, property name is case-insensitive);
  • the class has a member variable with the specified name (when $checkVars is true);
  • an attached behavior has a readable property of the given name (when $checkBehaviors is true).

See also canSetProperty().

public boolean canGetProperty ( $name, $checkVars true, $checkBehaviors true )
$name string

The property name

$checkVars boolean

Whether to treat member variables as properties

$checkBehaviors boolean

Whether to treat behaviors' properties as properties of this component

return boolean

Whether the property can be read

                public function canGetProperty($name, $checkVars = true, $checkBehaviors = true)
{
    if (method_exists($this, 'get' . $name) || $checkVars && property_exists($this, $name)) {
        return true;
    } elseif ($checkBehaviors) {
        $this->ensureBehaviors();
        foreach ($this->_behaviors as $behavior) {
            if ($behavior->canGetProperty($name, $checkVars)) {
                return true;
            }
        }
    }
    return false;
}

            
canSetProperty() public method

Defined in: yii\base\Component::canSetProperty()

Returns a value indicating whether a property can be set.

A property can be written if:

  • the class has a setter method associated with the specified name (in this case, property name is case-insensitive);
  • the class has a member variable with the specified name (when $checkVars is true);
  • an attached behavior has a writable property of the given name (when $checkBehaviors is true).

See also canGetProperty().

public boolean canSetProperty ( $name, $checkVars true, $checkBehaviors true )
$name string

The property name

$checkVars boolean

Whether to treat member variables as properties

$checkBehaviors boolean

Whether to treat behaviors' properties as properties of this component

return boolean

Whether the property can be written

                public function canSetProperty($name, $checkVars = true, $checkBehaviors = true)
{
    if (method_exists($this, 'set' . $name) || $checkVars && property_exists($this, $name)) {
        return true;
    } elseif ($checkBehaviors) {
        $this->ensureBehaviors();
        foreach ($this->_behaviors as $behavior) {
            if ($behavior->canSetProperty($name, $checkVars)) {
                return true;
            }
        }
    }
    return false;
}

            
className() public static method
Deprecated since 2.0.14. On PHP >=5.5, use ::class instead.

Defined in: yii\base\BaseObject::className()

Returns the fully qualified name of this class.

public static string className ( )
return string

The fully qualified name of this class.

                public static function className()
{
    return get_called_class();
}

            
createCmsBlockFixture() public method
public luya\testsuite\fixtures\ActiveRecordFixture createCmsBlockFixture ( array $fixtureData = [] )
$fixtureData array

                public function createCmsBlockFixture(array $fixtureData = [])
{
    return new NgRestModelFixture([
        'modelClass' => Block::class,
        'fixtureData' => $fixtureData,
    ]);
}

            
createCmsBlockGroupFixture() public method
public luya\testsuite\fixtures\ActiveRecordFixture createCmsBlockGroupFixture ( array $fixtureData = [] )
$fixtureData array

                public function createCmsBlockGroupFixture(array $fixtureData = [])
{
    return new NgRestModelFixture([
        'modelClass' => BlockGroup::class,
        'fixtureData' => $fixtureData,
    ]);
}

            
createCmsLayoutFixture() public method
public luya\testsuite\fixtures\ActiveRecordFixture createCmsLayoutFixture ( array $fixtureData = [] )
$fixtureData array

                public function createCmsLayoutFixture(array $fixtureData = [])
{
    return new NgRestModelFixture([
        'modelClass' => Layout::class,
        'fixtureData' => $fixtureData,
    ]);
}

            
createCmsLog() public method
public luya\testsuite\fixtures\ActiveRecordFixture createCmsLog ( array $fixtureData = [] )
$fixtureData array

                public function createCmsLog(array $fixtureData = [])
{
    return new ActiveRecordFixture([
        'modelClass' => Log::class,
        'fixtureData' => $fixtureData,
    ]);
}

            
createCmsNavContainerFixture() public method
public luya\testsuite\fixtures\ActiveRecordFixture createCmsNavContainerFixture ( array $fixtureData = [] )
$fixtureData array

                public function createCmsNavContainerFixture(array $fixtureData = [])
{
    return new NgRestModelFixture([
        'modelClass' => NavContainer::class,
        'fixtureData' => $fixtureData,
    ]);
}

            
createCmsNavFixture() public method
public luya\testsuite\fixtures\ActiveRecordFixture createCmsNavFixture ( array $fixtureData = [] )
$fixtureData array

                public function createCmsNavFixture(array $fixtureData = [])
{
    return new ActiveRecordFixture([
        'modelClass' => Nav::class,
        'fixtureData' => $fixtureData
    ]);
}

            
createCmsNavItemFixture() public method
public luya\testsuite\fixtures\ActiveRecordFixture createCmsNavItemFixture ( array $fixtureData = [] )
$fixtureData array

                public function createCmsNavItemFixture(array $fixtureData = [])
{
    return new ActiveRecordFixture([
        'modelClass' => NavItem::class,
        'fixtureData' => $fixtureData
    ]);
}

            
createCmsNavItemModuleFixture() public method
public luya\testsuite\fixtures\ActiveRecordFixture createCmsNavItemModuleFixture ( array $fixtureData = [] )
$fixtureData array

                public function createCmsNavItemModuleFixture(array $fixtureData = [])
{
    return new ActiveRecordFixture([
        'modelClass' => NavItemModule::class,
        'fixtureData' => $fixtureData,
    ]);
}

            
createCmsNavItemPageBlockItemFixture() public method

Defined in: luya\testsuite\traits\CmsDatabaseTableTrait::createCmsNavItemPageBlockItemFixture()

Create Cms Nav Item Page Block Item Fixture

public luya\testsuite\fixtures\ActiveRecordFixture createCmsNavItemPageBlockItemFixture ( array $fixtureData = [] )
$fixtureData array

                public function createCmsNavItemPageBlockItemFixture(array $fixtureData = [])
{
    return new ActiveRecordFixture([
        'modelClass' => NavItemPageBlockItem::class,
        'fixtureData' => $fixtureData,
    ]);
}

            
createCmsNavItemPageFixture() public method
public luya\testsuite\fixtures\ActiveRecordFixture createCmsNavItemPageFixture ( array $fixtureData = [] )
$fixtureData array

                public function createCmsNavItemPageFixture(array $fixtureData = [])
{
    return new ActiveRecordFixture([
        'modelClass' => NavItemPage::class,
        'fixtureData' => $fixtureData,
    ]);
}

            
createCmsNavItemRedirectFixture() public method
public luya\testsuite\fixtures\ActiveRecordFixture createCmsNavItemRedirectFixture ( array $fixtureData = [] )
$fixtureData array

                public function createCmsNavItemRedirectFixture(array $fixtureData = [])
{
    return new ActiveRecordFixture([
        'modelClass' => NavItemRedirect::class,
        'fixtureData' => $fixtureData,
    ]);
}

            
createCmsNavPermissionFixture() public method
public luya\testsuite\fixtures\ActiveRecordFixture createCmsNavPermissionFixture ( array $fixtureData = [] )
$fixtureData array

                public function createCmsNavPermissionFixture(array $fixtureData = [])
{
    return new ActiveRecordFixture([
        'modelClass' => NavPermission::class,
        'fixtureData' => $fixtureData,
    ]);
}

            
createCmsPropertyFixture() public method
public luya\testsuite\fixtures\ActiveRecordFixture createCmsPropertyFixture ( array $fixtureData = [] )
$fixtureData array

                public function createCmsPropertyFixture(array $fixtureData = [])
{
    return new ActiveRecordFixture([
        'modelClass' => Property::class,
        'fixtureData' => $fixtureData,
    ]);
}

            
createCmsRedirectFixture() public method
public luya\testsuite\fixtures\ActiveRecordFixture createCmsRedirectFixture ( array $fixtureData = [] )
$fixtureData array

                public function createCmsRedirectFixture(array $fixtureData = [])
{
    return new NgRestModelFixture([
        'modelClass' => Redirect::class,
        'fixtureData' => $fixtureData,
    ]);
}

            
createCmsWebsiteFixture() public method
public luya\testsuite\fixtures\ActiveRecordFixture createCmsWebsiteFixture ( array $fixtureData = [] )
$fixtureData array

                public function createCmsWebsiteFixture(array $fixtureData = [])
{
    return new NgRestModelFixture([
        'modelClass' => Website::class,
        'fixtureData' => $fixtureData,
    ]);
}

            
deleteHasCache() public method

Defined in: luya\traits\CacheableTrait::deleteHasCache()

Remove a value from the cache if caching is enabled.

public boolean deleteHasCache ( $key )
$key string|array

The cache identifier

return boolean

Whether delete of key has been success or not

                public function deleteHasCache($key)
{
    if ($this->isCachable()) {
        return Yii::$app->cache->delete($key);
    }
    
    return false;
}

            
detachBehavior() public method

Defined in: yii\base\Component::detachBehavior()

Detaches a behavior from the component.

The behavior's yii\base\Behavior::detach() method will be invoked.

public yii\base\Behavior|null detachBehavior ( $name )
$name string

The behavior's name.

return yii\base\Behavior|null

The detached behavior. Null if the behavior does not exist.

                public function detachBehavior($name)
{
    $this->ensureBehaviors();
    if (isset($this->_behaviors[$name])) {
        $behavior = $this->_behaviors[$name];
        unset($this->_behaviors[$name]);
        $behavior->detach();
        return $behavior;
    }
    return null;
}

            
detachBehaviors() public method

Defined in: yii\base\Component::detachBehaviors()

Detaches all behaviors from the component.

public void detachBehaviors ( )

                public function detachBehaviors()
{
    $this->ensureBehaviors();
    foreach ($this->_behaviors as $name => $behavior) {
        $this->detachBehavior($name);
    }
}

            
encodeValue() public method (available since version 1.0.7.2)

Defined in: luya\cms\Menu::encodeValue()

Determines and encodes the given value if enabled.

public string encodeValue ( $value )
$value string

The value to encode.

return string

The encoded value if enabled.

                public function encodeValue($value)
{
    return $this->encoding ? Html::encode($value) : $value;
}

            
ensureBehaviors() public method

Defined in: yii\base\Component::ensureBehaviors()

Makes sure that the behaviors declared in behaviors() are attached to this component.

public void ensureBehaviors ( )

                public function ensureBehaviors()
{
    if ($this->_behaviors === null) {
        $this->_behaviors = [];
        foreach ($this->behaviors() as $name => $behavior) {
            $this->attachBehaviorInternal($name, $behavior);
        }
    }
}

            
find() public method

Defined in: luya\cms\Menu::find()

Wrapper method for new \luya\cms\menu\Query() object.

public luya\cms\menu\Query find ( )

                public function find()
{
    return (new MenuQuery());
}

            
findAll() public method

Defined in: luya\cms\Menu::findAll()

Wrapper method to get all menu items for the current language without hidden items for the specific where statement.

See also luya\cms\menu\Query::where().

public luya\cms\menu\QueryIterator findAll ( array $where, $preloadModels false )
$where array

See {{\luya\cms\menu\Query::where()}}

$preloadModels boolean

Whether to preload all models for the given menu Query. See {{luya\cms\menu\Query::preloadModels()}}

                public function findAll(array $where, $preloadModels = false)
{
    return (new MenuQuery())->where($where)->preloadModels($preloadModels)->all();
}

            
findOne() public method

Defined in: luya\cms\Menu::findOne()

Wrapper method to get one menu item for current language without hidden items for the sepcific where statement.

See also luya\cms\menu\Query::where().

public luya\cms\menu\Item findOne ( array $where )
$where array

See {{\luya\cms\menu\Query::where()}}

                public function findOne(array $where)
{
    return (new MenuQuery())->where($where)->one();
}

            
flushCache() public method

Defined in: luya\cms\Menu::flushCache()

Flush all caching data for the menu for each language

public void flushCache ( )

                public function flushCache()
{
    foreach ($this->getLanguages() as $lang) {
        $this->deleteHasCache($this->_cachePrefix . $this->request->hostName . $lang['short_code']);
    }
}

            
flushHasCache() public method

Defined in: luya\traits\CacheableTrait::flushHasCache()

Deletes all values from cache.

public boolean flushHasCache ( )
return boolean

Whether the flush operation was successful.

                public function flushHasCache()
{
    if ($this->isCachable()) {
        return Yii::$app->cache->flush();
    }
    
    return false;
}

            
getBehavior() public method

Defined in: yii\base\Component::getBehavior()

Returns the named behavior object.

public yii\base\Behavior|null getBehavior ( $name )
$name string

The behavior name

return yii\base\Behavior|null

The behavior object, or null if the behavior does not exist

                public function getBehavior($name)
{
    $this->ensureBehaviors();
    return isset($this->_behaviors[$name]) ? $this->_behaviors[$name] : null;
}

            
getBehaviors() public method

Defined in: yii\base\Component::getBehaviors()

Returns all behaviors attached to this component.

public yii\base\Behavior[] getBehaviors ( )
return yii\base\Behavior[]

List of behaviors attached to this component

                public function getBehaviors()
{
    $this->ensureBehaviors();
    return $this->_behaviors;
}

            
getComposition() public method

Defined in: luya\cms\Menu::getComposition()

Get the composition component if not yet loaded.

public luya\web\Composition getComposition ( )
return luya\web\Composition

Object with composition informationes.

                public function getComposition()
{
    if ($this->_composition === null) {
        $this->_composition = Yii::$app->get('composition');
    }
    return $this->_composition;
}

            
getCurrent() public method

Defined in: luya\cms\Menu::getCurrent()

Get the current menu item resolved by active language (from composition).

public luya\cms\menu\Item getCurrent ( )
return luya\cms\menu\Item

An item-object for the current active item.

                public function getCurrent()
{
    if ($this->_current === null) {
        $this->_current = $this->resolveCurrent();
        $this->trigger(self::EVENT_AFTER_RESOLVE_CURRENT);
    }
    return $this->_current;
}

            
getCurrentAppendix() public method

Defined in: luya\cms\Menu::getCurrentAppendix()

Returns the parts of the rules who do not belong to the current active menu item link.

For instance the current menu link is /de/company/news where this page is declared as a module with urlRules, controllers and actions. If the url path is /de/company/news/detail/my-first-news the appendix would be detail/my-first-news.

public string getCurrentAppendix ( )
return string

The url part not related for the current active link

                public function getCurrentAppendix()
{
    if ($this->_current === null) {
        $this->_current = $this->resolveCurrent();
    }
    return $this->_currentAppendix;
}

            
getCurrentUrlRule() public method

Defined in: luya\cms\Menu::getCurrentUrlRule()

Get the url rules for the current menu item.

public array getCurrentUrlRule ( )

                public function getCurrentUrlRule()
{
    return $this->_currentUrlRule;
}

            
getHasCache() public method

Defined in: luya\traits\CacheableTrait::getHasCache()

Get the caching data if caching is allowed and there is any data stored for this key.

public mixed|boolean getHasCache ( $key )
$key string|array

The identifiere key, can be a string or an array which will be calculated.

return mixed|boolean

Returns the data, if not found returns false.

                public function getHasCache($key)
{
    if ($this->isCachable()) {
        $data = Yii::$app->cache->get($key);
        
        $enumKey = (is_array($key)) ? implode(",", $key) : $key;
        
        if ($data) {
            Yii::debug("Cacheable trait key '$enumKey' successfully loaded from cache.", __METHOD__);
            return $data;
        }
        Yii::debug("Cacheable trait key '$enumKey' has not been found in cache.", __METHOD__);
    }

    return false;
}

            
getHome() public method

Defined in: luya\cms\Menu::getHome()

Return the home site for the current resolved language resolved by {{luya\web\Composition}} component.

public luya\cms\menu\Item getHome ( )
return luya\cms\menu\Item

An item-object for the home item for the current resolved language.

                public function getHome()
{
    return (new MenuQuery())->where([self::FIELD_ISHOME => 1])->with('hidden')->one();
}

            
getLanguage() public method

Defined in: luya\cms\Menu::getLanguage()

Get languag information for a specific language short code.

public array|boolean getLanguage ( $shortCode )
$shortCode string

E.g. de or en

return array|boolean

If the shortCode exists an array with informations as returned, otherwise false.

                public function getLanguage($shortCode)
{
    return (array_key_exists($shortCode, $this->getLanguages())) ? $this->getLanguages()[$shortCode] : false;
}

            
getLanguageContainer() public method

Defined in: luya\cms\Menu::getLanguageContainer()

Load and return the language container for the specific langShortCode, this method is used when using the ArrayAccess offsetGet() method.

public array getLanguageContainer ( $langShortCode )
$langShortCode string

A language short code which have to access in $this->getLanguages().

return array

An array containing all items in theyr keys for the provided language short code.

                public function getLanguageContainer($langShortCode)
{
    if (!array_key_exists($langShortCode, $this->_languageContainer)) {
        $this->_languageContainer[$langShortCode] = $this->loadWebsiteLanguageContainer($langShortCode);
        $this->trigger(self::EVENT_AFTER_LOAD);
    }
    return $this->_languageContainer[$langShortCode];
}

            
getLanguages() public method

Defined in: luya\cms\Menu::getLanguages()

Get an array with all available system languages based on the admin_lang table.

public array getLanguages ( )
return array

An array where the key is the short_code and the value an array containing shortcode and id.

                public function getLanguages()
{
    if ($this->_languages === null) {
        $this->_languages = (new DbQuery())->select(['short_code', 'id'])->indexBy('short_code')->from('admin_lang')->all();
    }
    return $this->_languages;
}

            
getLevelContainer() public method

Defined in: luya\cms\Menu::getLevelContainer()

Get all items for a specific level.

public array|luya\cms\menu\QueryIterator getLevelContainer ( $level, luya\cms\menu\Item $baseItem null )
$level integer

Define the level you like to get the items from, the hirarchy starts by the level 1, which is the root line.

$baseItem luya\cms\menu\Item

Provide an optional element which represents the base calculation item for Theme siblings/children calculation, this can be case when you have several contains do not want to use the "current" Item as base calucation, because getCurrent() could be in another container so it would get you all level container items for this container.

return array|luya\cms\menu\QueryIterator

All siblings or children items, if not found an empty array will return.

                public function getLevelContainer($level, Item $baseItem = null)
{
    // define if the requested level is the root line (level 1) or not
    $rootLine = ($level === 1) ? true : false;
    // countdown the level (as we need the parent of the element to get the children
    $level--;
    // foreach counter
    $i = 1;
    if ($baseItem === null) {
        $baseItem = $this->getCurrent();
    }
    // foreach
    foreach ($baseItem->with('hidden')->getTeardown() as $item) {
        // if its the root line an match level 1 get all siblings
        if ($rootLine && $i == 1) {
            return $item->without(['hidden'])->siblings;
        } elseif ($i == $level) {
            return $item->without(['hidden'])->children;
        }
        $i++;
    }
    // no no container found for the defined level
    return [];
}

            
getLevelCurrent() public method

Defined in: luya\cms\Menu::getLevelCurrent()

Get the current item for specified level/depth. Menus always start on level/depth 1. This works only in reversed order, to get the parent level from a child!

public luya\cms\menu\Item|boolean getLevelCurrent ( $level )
$level integer

Level menu starts with 1

return luya\cms\menu\Item|boolean

An item-object for the specific level current, false otherwise.

                public function getLevelCurrent($level)
{
    $i = 1;
    foreach ($this->getCurrent()->with('hidden')->getTeardown() as $item) {
        if ($i == $level) {
            return $item;
        }
        ++$i;
    }
    return false;
}

            
getModulesMap() public method

Defined in: luya\cms\Menu::getModulesMap()

Return all nav item modules to request data later in items

public array getModulesMap ( )
return array

An array with all modules index by the id

                public function getModulesMap()
{
    if ($this->_modulesMap === null) {
        $this->_modulesMap = NavItemModule::find()->select(['module_name', 'id'])->indexBy('id')->asArray()->all();
    }
    return $this->_modulesMap;
}

            
getOrSetHasCache() public method

Defined in: luya\traits\CacheableTrait::getOrSetHasCache()

Method combines both setHasCache() and getHasCache() methods to retrieve value identified by a $key, or to store the result of $closure execution if there is no cache available for the $key.

Usage example:

use CacheableTrait;

public function getTopProducts($count = 10)
{
    return $this->getOrSetHasCache(['top-n-products', 'n' => $count], function ($cache) use ($count) {
        return Products::find()->mostPopular()->limit(10)->all();
    }, 1000);
}
public mixed getOrSetHasCache ( $key, Closure $closure, $duration null, $dependency null )
$key mixed

A key identifying the value to be cached. This can be a simple string or a complex data structure consisting of factors representing the key.

$closure Closure

The closure that will be used to generate a value to be cached. In case $closure returns false, the value will not be cached.

$duration integer

Default duration in seconds before the cache will expire. If not set, defaultDuration value will be used. 0 means never expire.

$dependency yii\caching\Dependency

Dependency of the cached item. If the dependency changes, the corresponding value in the cache will be invalidated when it is fetched via get(). This parameter is ignored if serializer is false.

return mixed

Result of $closure execution

                public function getOrSetHasCache($key, \Closure $closure, $duration = null, $dependency = null)
{
    if (($value = $this->getHasCache($key)) !== false) {
        return $value;
    }
    
    $value = call_user_func($closure, $this);
    
    $this->setHasCache($key, $value, $dependency, $duration);
    
    return $value;
}

            
getRedirectMap() public method

Defined in: luya\cms\Menu::getRedirectMap()

Get an array containing all redirect items from the database table cms_nav_item_redirect.

public array getRedirectMap ( )
return array

An array where the key is the id and the value an array containing id, type and value.

                public function getRedirectMap()
{
    if ($this->_redirectMap === null) {
        $this->_redirectMap = (new DbQuery())->select(['id', 'type', 'value', 'target'])->from('cms_nav_item_redirect')->indexBy('id')->all();
    }
    return $this->_redirectMap;
}

            
hasEventHandlers() public method

Defined in: yii\base\Component::hasEventHandlers()

Returns a value indicating whether there is any handler attached to the named event.

public boolean hasEventHandlers ( $name )
$name string

The event name

return boolean

Whether there is any handler attached to the event.

                public function hasEventHandlers($name)
{
    $this->ensureBehaviors();
    if (!empty($this->_events[$name])) {
        return true;
    }
    foreach ($this->_eventWildcards as $wildcard => $handlers) {
        if (!empty($handlers) && StringHelper::matchWildcard($wildcard, $name)) {
            return true;
        }
    }
    return Event::hasHandlers($this, $name);
}

            
hasMethod() public method

Defined in: yii\base\Component::hasMethod()

Returns a value indicating whether a method is defined.

A method is defined if:

  • the class has a method with the specified name
  • an attached behavior has a method with the given name (when $checkBehaviors is true).
public boolean hasMethod ( $name, $checkBehaviors true )
$name string

The property name

$checkBehaviors boolean

Whether to treat behaviors' methods as methods of this component

return boolean

Whether the method is defined

                public function hasMethod($name, $checkBehaviors = true)
{
    if (method_exists($this, $name)) {
        return true;
    } elseif ($checkBehaviors) {
        $this->ensureBehaviors();
        foreach ($this->_behaviors as $behavior) {
            if ($behavior->hasMethod($name)) {
                return true;
            }
        }
    }
    return false;
}

            
hasProperty() public method

Defined in: yii\base\Component::hasProperty()

Returns a value indicating whether a property is defined for this component.

A property is defined if:

  • the class has a getter or setter method associated with the specified name (in this case, property name is case-insensitive);
  • the class has a member variable with the specified name (when $checkVars is true);
  • an attached behavior has a property of the given name (when $checkBehaviors is true).

See also:

public boolean hasProperty ( $name, $checkVars true, $checkBehaviors true )
$name string

The property name

$checkVars boolean

Whether to treat member variables as properties

$checkBehaviors boolean

Whether to treat behaviors' properties as properties of this component

return boolean

Whether the property is defined

                public function hasProperty($name, $checkVars = true, $checkBehaviors = true)
{
    return $this->canGetProperty($name, $checkVars, $checkBehaviors) || $this->canSetProperty($name, false, $checkBehaviors);
}

            
init() public method

Initializes the object.

This method is invoked at the end of the constructor after the object is initialized with the given configuration.

public void init ( )

                public function init()
{
    $langFixtures  = [];
    $langId = 1;
    foreach ($this->items as $lang => $items) {
        $langFixtures[] = [
            'id' => $langId,
            'short_code' => $lang,
            'name' => $lang,
            'is_default' => $langId == 1 ? 1 : 0,
            'is_deleted' => 0,
        ];
        $langId++;
        $this->setLanguageContainer($lang, $this->normalizeItems($items, $lang));
    }
    $this->createAdminLangFixture($langFixtures);
    parent::init();
}

            
injectItem() public method
public void injectItem ( luya\cms\menu\InjectItemInterface $item )
$item luya\cms\menu\InjectItemInterface

                public function injectItem(InjectItemInterface $item)
{
    $this->_languageContainer[$item->getLang()][$item->getId()] = $item->toArray();
}

            
isCachable() public method

Defined in: luya\traits\CacheableTrait::isCachable()

Check if the current configuration of the application and the property allows a caching of the language container data.

public boolean isCachable ( )

                public function isCachable()
{
    if ($this->_cachable === null) {
        $this->_cachable = Yii::$app->has('cache') ? true : false;
    }

    return $this->_cachable;
}

            
itemToStructure() protected method

Generate Menu structure for item.

protected array itemToStructure ( $item, $lang, $parentNavId )
$item string
$lang string
$parentNavId integer

                protected function itemToStructure($item, $lang, $parentNavId)
{
    $id = ArrayHelper::getValue($item, 'id');
    $title = ArrayHelper::getValue($item, 'title');
    return [
        'id' => $id,
        'nav_id' => ArrayHelper::getValue($item, 'nav_id', $id),
        'lang' => ArrayHelper::getValue($item, 'lang', $lang),
        'parent_nav_id' => ArrayHelper::getValue($item, 'parent_nav_id', $parentNavId),
        'link' => ArrayHelper::getValue($item, 'link', Inflector::slug($title)),
        'title' => $title,
        'alias' => ArrayHelper::getValue($item, 'alias', Inflector::slug($title)),
        'description' => ArrayHelper::getValue($item, 'description', ''),
        'keywords' => ArrayHelper::getValue($item, 'keywords', ''),
        'create_user_id' => ArrayHelper::getValue($item, 'create_user_id', 1),
        'update_user_id' => ArrayHelper::getValue($item, 'update_user_id', 1),
        'timestamp_create' => 1457091369,
        'timestamp_update' => 1483367249,
        'is_home' => ArrayHelper::getValue($item, 'is_home', 0),
        'sort_index' => ArrayHelper::getValue($item, 'sort_index', $id),
        'is_hidden' => ArrayHelper::getValue($item, 'is_hidden', 0),
        'type' => 1, // page
        'nav_item_type_id' => $id,
        'redirect' => false,
        'module_name' => false,
        'container' => ArrayHelper::getValue($item, 'container', 'default'),
        'depth' => ArrayHelper::getValue($item, 'depth', 1),
        'image_id' => ArrayHelper::getValue($item, 'image_id', 0),
        'is_url_strict_parsing_disabled' => 1,
    ];
}

            
normalizeItems() protected method

Generate a flat menu structure from items.

protected array normalizeItems ( array $items, $lang, $parentNavId 0 )
$items array
$lang string
$parentNavId integer

                protected function normalizeItems(array $items, $lang, $parentNavId = 0)
{
    $data = [];
    foreach ($items as $key => $item) {
        if (!is_array($item)) {
            $item = ['id' => $key, 'title' => $item];
        }
        $normalized = $this->itemToStructure($item, $lang, $parentNavId);
        $data[$normalized['id']] = $normalized;
        if (isset($item['items'])) {
            $data = ArrayHelper::merge($data, $this->normalizeItems($item['items'], $lang, $item['id']));
        }
    }
    return $data;
}

            
off() public method

Defined in: yii\base\Component::off()

Detaches an existing event handler from this component.

This method is the opposite of on().

Note: in case wildcard pattern is passed for event name, only the handlers registered with this wildcard will be removed, while handlers registered with plain names matching this wildcard will remain.

See also on().

public boolean off ( $name, $handler null )
$name string

Event name

$handler callable|null

The event handler to be removed. If it is null, all handlers attached to the named event will be removed.

return boolean

If a handler is found and detached

                public function off($name, $handler = null)
{
    $this->ensureBehaviors();
    if (empty($this->_events[$name]) && empty($this->_eventWildcards[$name])) {
        return false;
    }
    if ($handler === null) {
        unset($this->_events[$name], $this->_eventWildcards[$name]);
        return true;
    }
    $removed = false;
    // plain event names
    if (isset($this->_events[$name])) {
        foreach ($this->_events[$name] as $i => $event) {
            if ($event[0] === $handler) {
                unset($this->_events[$name][$i]);
                $removed = true;
            }
        }
        if ($removed) {
            $this->_events[$name] = array_values($this->_events[$name]);
            return true;
        }
    }
    // wildcard event names
    if (isset($this->_eventWildcards[$name])) {
        foreach ($this->_eventWildcards[$name] as $i => $event) {
            if ($event[0] === $handler) {
                unset($this->_eventWildcards[$name][$i]);
                $removed = true;
            }
        }
        if ($removed) {
            $this->_eventWildcards[$name] = array_values($this->_eventWildcards[$name]);
            // remove empty wildcards to save future redundant regex checks:
            if (empty($this->_eventWildcards[$name])) {
                unset($this->_eventWildcards[$name]);
            }
        }
    }
    return $removed;
}

            
offsetExists() public method

Defined in: luya\cms\Menu::offsetExists()

ArrayAccess check if the offset key exists in the language array.

public boolean offsetExists ( $offset )
$offset string

Language short code the verify

                #[\ReturnTypeWillChange]
public function offsetExists($offset)
{
    return ($this->getLanguage($offset)) ? true : false;
}

            
offsetGet() public method

Defined in: luya\cms\Menu::offsetGet()

ArrayAccess get the current offset key if not yet loaded.

public array|mixed offsetGet ( $offset )
$offset string

Language short code to get

                #[\ReturnTypeWillChange]
public function offsetGet($offset)
{
    return $this->getLanguageContainer($offset);
}

            
offsetSet() public method

Defined in: luya\cms\Menu::offsetSet()

ArrayAccess offsetSet is not implemented in singleton component.

public void offsetSet ( $offset, $value )
$offset string
$value string
throws luya\cms\Exception

Always throws exception as this method is not implemented.

                #[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
    throw new Exception('The set method is disabled for this component.');
}

            
offsetUnset() public method

Defined in: luya\cms\Menu::offsetUnset()

ArrayAccess offsetSet is not implemented in singleton component.

public void offsetUnset ( $offset )
$offset string
throws luya\cms\Exception

Always throws exception as this method is not implemented.

                #[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
    throw new Exception('The unset method is disabled for this component.');
}

            
on() public method

Defined in: yii\base\Component::on()

Attaches an event handler to an event.

The event handler must be a valid PHP callback. The following are some examples:

function ($event) { ... }         // anonymous function
[$object, 'handleClick']          // $object->handleClick()
['Page', 'handleClick']           // Page::handleClick()
'handleClick'                     // global function handleClick()

The event handler must be defined with the following signature,

function ($event)

where $event is an yii\base\Event object which includes parameters associated with the event.

Since 2.0.14 you can specify event name as a wildcard pattern:

$component->on('event.group.*', function ($event) {
    Yii::trace($event->name . ' is triggered.');
});

See also off().

public void on ( $name, $handler, $data null, $append true )
$name string

The event name

$handler callable

The event handler

$data mixed

The data to be passed to the event handler when the event is triggered. When the event handler is invoked, this data can be accessed via yii\base\Event::$data.

$append boolean

Whether to append new event handler to the end of the existing handler list. If false, the new handler will be inserted at the beginning of the existing handler list.

                public function on($name, $handler, $data = null, $append = true)
{
    $this->ensureBehaviors();
    if (strpos($name, '*') !== false) {
        if ($append || empty($this->_eventWildcards[$name])) {
            $this->_eventWildcards[$name][] = [$handler, $data];
        } else {
            array_unshift($this->_eventWildcards[$name], [$handler, $data]);
        }
        return;
    }
    if ($append || empty($this->_events[$name])) {
        $this->_events[$name][] = [$handler, $data];
    } else {
        array_unshift($this->_events[$name], [$handler, $data]);
    }
}

            
setCurrent() public method (available since version 1.0.0)

Defined in: luya\cms\Menu::setCurrent()

Ability to override the current item in order to make real preview urls (as when resolver does not work of changed urls).

public void setCurrent ( luya\cms\menu\Item $item )
$item luya\cms\menu\Item

The current item object

                public function setCurrent(Item $item)
{
    $this->_current = $item;
}

            
setCurrentUrlRule() public method

Defined in: luya\cms\Menu::setCurrentUrlRule()

Set url rules for the current page item in order to retrieve at another point of the appliation when building language links.

public void setCurrentUrlRule ( array $rule )
$rule array

                public function setCurrentUrlRule(array $rule)
{
    $this->_currentUrlRule = $rule;
}

            
setHasCache() public method

Defined in: luya\traits\CacheableTrait::setHasCache()

Store cache data for a specific key if caching is enabled in this application.

public boolean setHasCache ( $key, $value, $dependency null, $cacheExpiration null )
$key string|array

The identifier key or a array to store complex keys

$value mixed

The value to store in the cache component.

$dependency yii\caching\Dependency|array

Dependency of the cached item. If the dependency changes, the corresponding value in the cache will be invalidated when it is fetched via get(). This parameter is ignored if $serializer is false. You can also define an array with defintion which will generate the Object instead of object is provided.

$cacheExpiration

Integer The time in seconds before the cache data expires, 0 means never expire.

return boolean

Whether set has been success or not

                public function setHasCache($key, $value, $dependency = null, $cacheExpiration = null)
{
    if ($this->isCachable()) {
        if (is_array($dependency)) {
            $dependency = Yii::createObject($dependency);
        }
        
        return Yii::$app->cache->set($key, $value, is_null($cacheExpiration) ? $this->_cacheExpiration : $cacheExpiration, $dependency);
    }
    
    return false;
}

            
setLanguageContainer() public method

Defined in: luya\cms\Menu::setLanguageContainer()

Setter method for the language container.

This is maily used when working with unit test.

Example Data array:

[
	43 => [
   		'id' => '43',
   		'nav_id' => '1',
   		'lang' => 'fr',
  		'link' => '/public_html/fr/home',
   		'title' => 'Homepage',
    		'alias' => 'home',
    		'description' => '',
    		'keywords' => NULL,
    		'create_user_id' => '4',
    		'update_user_id' => '4',
    		'timestamp_create' => '1457091369',
    		'timestamp_update' => '1483367249',
    		'is_home' => '1',
    		'parent_nav_id' => '0',
    		'sort_index' => '1',
    		'is_hidden' => '1',
   		'type' => '1',
    		'nav_item_type_id' => '42',
    		'redirect' => false,
    		'module_name' => false,
    		'container' => 'default',
    		'depth' => 1,
         'image_id' => 0,
         'is_url_strict_parsing_disabled' => 1,
		],
]
public void setLanguageContainer ( $langShortCode, array $data )
$langShortCode string
$data array

An array with items based on the database [0 => ['id' => 1, 'nav_id' => 2, ... ]]

                public function setLanguageContainer($langShortCode, array $data)
{
    $this->_languageContainer[$langShortCode] = $data;
}

            
trigger() public method

Defined in: yii\base\Component::trigger()

Triggers an event.

This method represents the happening of an event. It invokes all attached handlers for the event including class-level handlers.

public void trigger ( $name, yii\base\Event $event null )
$name string

The event name

$event yii\base\Event|null

The event instance. If not set, a default yii\base\Event object will be created.

                public function trigger($name, Event $event = null)
{
    $this->ensureBehaviors();
    $eventHandlers = [];
    foreach ($this->_eventWildcards as $wildcard => $handlers) {
        if (StringHelper::matchWildcard($wildcard, $name)) {
            $eventHandlers[] = $handlers;
        }
    }
    if (!empty($this->_events[$name])) {
        $eventHandlers[] = $this->_events[$name];
    }
    if (!empty($eventHandlers)) {
        $eventHandlers = call_user_func_array('array_merge', $eventHandlers);
        if ($event === null) {
            $event = new Event();
        }
        if ($event->sender === null) {
            $event->sender = $this;
        }
        $event->handled = false;
        $event->name = $name;
        foreach ($eventHandlers as $handler) {
            $event->data = $handler[1];
            call_user_func($handler[0], $event);
            // stop further handling if the event is handled
            if ($event->handled) {
                return;
            }
        }
    }
    // invoke class-level attached handlers
    Event::trigger($this, $name, $event);
}