| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <?php
- /* * ********************************************************************
- * KerioEmail product developed. (Nov 19, 2018)
- * *
- *
- * CREATED BY THURDATA -> http://thurdata.com
- * CONTACT -> contact@thurdata.com
- *
- *
- * This software is furnished under a license and may be used and copied
- * only in accordance with the terms of such license and with the
- * inclusion of the above copyright notice. This software or any other
- * copies thereof may not be provided or otherwise made available to any
- * other person. No title to and ownership of the software is hereby
- * transferred.
- *
- *
- * ******************************************************************** */
- namespace ThurData\Servers\KerioEmail\Core\UI\Widget\Sidebar;
- /**
- * Description of SidebarTrait
- *
- * @autor ThurData <info@thurdata.ch>
- */
- trait SidebarTrait
- {
- protected $order;
- protected $targetBlank = false;
- protected $children = [];
- /**
- * @var Sidebar
- */
- protected $parent;
- protected $active=false;
-
- /**
- * Add Sidebar
- * @param \ThurData\Servers\KerioEmail\Core\UI\Widget\Sidebar\Sidebar $sidebar
- * @return \ThurData\Servers\KerioEmail\Core\UI\Widget\Sidebar\Sidebar
- */
- public function add( $sidebar)
- {
- $this->children[$sidebar->getId()] = $sidebar;
- $sidebar->setParent($this);
- return $this;
- }
-
- public function getChild($id){
- if(!isset($this->children[$id])){
- throw new \Exception(sprintf("Sidebar %s does not exist", $id));
- }
- return $this->children[$id];
- }
-
- public function hasChildren(){
- return !empty($this->children);
- }
-
- public function childrenDelete($id){
- if(!isset($this->children[$id])){
- throw new \Exception(sprintf("Sidebar children %s does not exist", $id));
- }
- unset ($this->children[$id]);
- }
-
- /**
- * @return Sidebar[]
- */
- public function getChildren(){
- return $this->children;
- }
-
- public function destroy(){
- unset($this->children);
- return $this;
- }
-
- public function getParent()
- {
- return $this->parent;
- }
- public function setParent($parent)
- {
- $this->parent = $parent;
- return $this;
- }
- public function delete()
- {
- if ($this->id)
- {
- $this->parent->childrenDelete($this->id);
- }
- }
-
- public function isActive()
- {
- return $this->active===true;
- }
- public function setActive($active)
- {
- $this->active = (boolean)$active;
- return $this;
- }
- public function setOrder($order)
- {
- $this->order = $order;
- return $this;
- }
-
- public function getOrder()
- {
- return $this->order;
- }
- }
|