TrackManiaControl/libs/FML/Script/Features/MenuElement.php

99 lines
1.9 KiB
PHP
Raw Normal View History

2014-04-27 14:44:40 +02:00
<?php
namespace FML\Script\Features;
use FML\Controls\Control;
2014-05-14 23:24:00 +02:00
use FML\Types\Scriptable;
2014-04-27 14:44:40 +02:00
/**
2014-06-21 03:18:21 +02:00
* Menu Element for the Menu Feature
2014-04-27 14:44:40 +02:00
*
2014-05-20 15:44:45 +02:00
* @author steeffeen <mail@steeffeen.com>
2017-03-25 18:40:15 +01:00
* @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder
2014-05-14 23:24:00 +02:00
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
2014-04-27 14:44:40 +02:00
*/
2017-03-25 18:40:15 +01:00
class MenuElement
{
2014-04-27 14:44:40 +02:00
2017-03-25 18:40:15 +01:00
/**
* @var Control $item Menu Item
*/
protected $item = null;
2014-04-27 14:44:40 +02:00
2017-03-25 18:40:15 +01:00
/**
* @var Control $control Menu Control
*/
protected $control = null;
2014-04-27 14:44:40 +02:00
2017-03-25 18:40:15 +01:00
/**
* Create a new Menu Element
*
* @api
* @param Control $item (optional) Item Control in the Menu bar
* @param Control $control (optional) Toggled Menu Control
*/
public function __construct(Control $item = null, Control $control = null)
{
if ($item) {
$this->setItem($item);
}
if ($control) {
$this->setControl($control);
}
}
2014-04-27 14:44:40 +02:00
2017-03-25 18:40:15 +01:00
/**
* Get the Item Control
*
* @api
* @return Control
*/
public function getItem()
{
return $this->item;
}
/**
* Set the Item Control
*
* @api
* @param Control $item Item Control
* @return static
*/
public function setItem(Control $item)
{
$item->checkId();
if ($item instanceof Scriptable) {
$item->setScriptEvents(true);
}
$this->item = $item;
return $this;
}
/**
* Get the Menu Control
*
* @api
* @return Control
*/
public function getControl()
{
return $this->control;
}
/**
* Set the Menu Control
*
* @api
* @param Control $control Menu Control
* @return static
*/
public function setControl(Control $control)
{
$control->checkId();
$this->control = $control;
return $this;
}
2014-04-27 14:44:40 +02:00
}