ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\Tree\TreeBuilder Class Reference

@template-extends \ilTree More...

+ Collaboration diagram for ILIAS\Tree\TreeBuilder:

Public Member Functions

 __construct (int $tree_id)
 Create a new TreeBuilder instance. More...
 
 withTreeId (int $tree_id)
 Set the tree identifier. More...
 
 withRootId (int $root_id)
 Set the root node identifier. More...
 
 withDatabase (\ilDBInterface $db)
 Set the database interface. More...
 
 withLogger (LoggerInterface $logger)
 Set the logger. More...
 
 withSetting (Setting $setting)
 Set the settings. More...
 
 withEventHandler (\ilAppEventHandler $event_handler)
 Set the event handler. More...
 
 withObjectDataCache (\ilObjectDataCache $obj_data_cache)
 Set the object data cache. More...
 
 withObjectDefinition (\ilObjectDefinition $obj_definition)
 Set the object definition. More...
 
 withUser (\ilObjUser $user)
 Set the current user. More...
 
 withLanguage (Language $language)
 Set the language handler. More...
 
 forSetupEnvironment (\ilDBInterface $db, Setting $setting)
 Configure the builder for a setup environment with minimal dependencies. More...
 
 forMainTree ()
 Configure the builder for a main tree (default repository tree). More...
 
 forSubTree (int $root_id)
 Configure the builder for a subtree. More...
 
 build ()
 Build and return the ilTree instance. More...
 

Private Attributes

int $tree_id
 
int $root_id = 0
 
ilDBInterface $db = null
 
LoggerInterface $logger = null
 
Setting $setting = null
 
ilAppEventHandler $event_handler = null
 
ilObjectDataCache $obj_data_cache = null
 
ilObjectDefinition $obj_definition = null
 
ilObjUser $user = null
 
Language $language = null
 

Detailed Description

@template-extends \ilTree

Builder class for ilTree instances. Provides a fluent interface for constructing tree instances with various configurations.

Author
ILIAS Development

Definition at line 39 of file TreeBuilder.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Tree\TreeBuilder::__construct ( int  $tree_id)

Create a new TreeBuilder instance.

Parameters
int$tree_idThe tree identifier (required)

Definition at line 57 of file TreeBuilder.php.

58 {
59 $this->tree_id = $tree_id;
60 }

References ILIAS\Tree\TreeBuilder\$tree_id.

Member Function Documentation

◆ build()

ILIAS\Tree\TreeBuilder::build ( )

Build and return the ilTree instance.

Returns
\ilTree The constructed tree instance

Definition at line 228 of file TreeBuilder.php.

228 : \ilTree
229 {
230 return new \ilTree(
231 $this->tree_id,
232 $this->root_id,
233 $this->db,
234 $this->logger,
235 $this->setting,
236 $this->event_handler,
237 $this->obj_data_cache,
238 $this->obj_definition,
239 $this->user,
240 $this->language
241 );
242 }
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...

References ILIAS\UI\examples\Symbol\Glyph\Language\language(), ILIAS\Repository\logger(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ forMainTree()

ILIAS\Tree\TreeBuilder::forMainTree ( )

Configure the builder for a main tree (default repository tree).

Returns
$this

Definition at line 204 of file TreeBuilder.php.

204 : self
205 {
206 $this->root_id = defined("ROOT_FOLDER_ID") ? ROOT_FOLDER_ID : 0;
207
208 return $this;
209 }
const ROOT_FOLDER_ID
Definition: constants.php:32

References ROOT_FOLDER_ID.

◆ forSetupEnvironment()

ILIAS\Tree\TreeBuilder::forSetupEnvironment ( \ilDBInterface  $db,
Setting  $setting 
)

Configure the builder for a setup environment with minimal dependencies.

This is a convenience method that sets up the builder with null/fallback values for dependencies that may not be available in setup contexts.

Parameters
\ilDBInterface$dbRequired database connection
Returns
$this

Definition at line 190 of file TreeBuilder.php.

190 : self
191 {
192 $this->db = $db;
193 $this->setting = $setting;
194 $this->logger = new \ILIAS\Tree\Logging\NullLogger();
195 $this->language = new \ILIAS\Tree\Language\NullLanguage();
196 return $this;
197 }

References ILIAS\Tree\TreeBuilder\$db, ILIAS\Tree\TreeBuilder\$setting, ILIAS\UI\examples\Symbol\Glyph\Language\language(), and ILIAS\Repository\logger().

+ Here is the call graph for this function:

◆ forSubTree()

ILIAS\Tree\TreeBuilder::forSubTree ( int  $root_id)

Configure the builder for a subtree.

Parameters
int$root_idThe root node ID for the subtree
Returns
$this

Definition at line 217 of file TreeBuilder.php.

217 : self
218 {
219 $this->root_id = $root_id;
220 return $this;
221 }

References ILIAS\Tree\TreeBuilder\$root_id.

◆ withDatabase()

ILIAS\Tree\TreeBuilder::withDatabase ( \ilDBInterface  $db)

Set the database interface.

Parameters
\ilDBInterface$dbDatabase interface
Returns
$this

Definition at line 92 of file TreeBuilder.php.

92 : self
93 {
94 $this->db = $db;
95 return $this;
96 }

References ILIAS\Tree\TreeBuilder\$db.

◆ withEventHandler()

ILIAS\Tree\TreeBuilder::withEventHandler ( \ilAppEventHandler  $event_handler)

Set the event handler.

Parameters
\ilAppEventHandler$event_handlerEvent handler
Returns
$this

Definition at line 128 of file TreeBuilder.php.

128 : self
129 {
130 $this->event_handler = $event_handler;
131 return $this;
132 }
ilAppEventHandler $event_handler
Definition: TreeBuilder.php:46

References ILIAS\Tree\TreeBuilder\$event_handler.

◆ withLanguage()

ILIAS\Tree\TreeBuilder::withLanguage ( Language  $language)

Set the language handler.

Parameters
Language$languageLanguage instance
Returns
$this

Definition at line 176 of file TreeBuilder.php.

176 : self
177 {
178 $this->language = $language;
179 return $this;
180 }

References ILIAS\Tree\TreeBuilder\$language, and ILIAS\UI\examples\Symbol\Glyph\Language\language().

+ Here is the call graph for this function:

◆ withLogger()

ILIAS\Tree\TreeBuilder::withLogger ( LoggerInterface  $logger)

Set the logger.

Parameters
LoggerInterface$loggerLogger instance
Returns
$this

Definition at line 104 of file TreeBuilder.php.

104 : self
105 {
106 $this->logger = $logger;
107 return $this;
108 }
LoggerInterface $logger
Definition: TreeBuilder.php:44

References ILIAS\Tree\TreeBuilder\$logger, and ILIAS\Repository\logger().

+ Here is the call graph for this function:

◆ withObjectDataCache()

ILIAS\Tree\TreeBuilder::withObjectDataCache ( \ilObjectDataCache  $obj_data_cache)

Set the object data cache.

Parameters
\ilObjectDataCache$obj_data_cacheObject data cache
Returns
$this

Definition at line 140 of file TreeBuilder.php.

140 : self
141 {
142 $this->obj_data_cache = $obj_data_cache;
143 return $this;
144 }
ilObjectDataCache $obj_data_cache
Definition: TreeBuilder.php:47

References ILIAS\Tree\TreeBuilder\$obj_data_cache.

◆ withObjectDefinition()

ILIAS\Tree\TreeBuilder::withObjectDefinition ( \ilObjectDefinition  $obj_definition)

Set the object definition.

Parameters
\ilObjectDefinition$obj_definitionObject definition
Returns
$this

Definition at line 152 of file TreeBuilder.php.

152 : self
153 {
154 $this->obj_definition = $obj_definition;
155 return $this;
156 }
ilObjectDefinition $obj_definition
Definition: TreeBuilder.php:48

References ILIAS\Tree\TreeBuilder\$obj_definition.

◆ withRootId()

ILIAS\Tree\TreeBuilder::withRootId ( int  $root_id)

Set the root node identifier.

Parameters
int$root_idRoot node identifier (defaults to ROOT_FOLDER_ID if 0)
Returns
$this

Definition at line 80 of file TreeBuilder.php.

80 : self
81 {
82 $this->root_id = $root_id;
83 return $this;
84 }

References ILIAS\Tree\TreeBuilder\$root_id.

◆ withSetting()

ILIAS\Tree\TreeBuilder::withSetting ( Setting  $setting)

Set the settings.

Parameters
Setting$settingSettings instance
Returns
$this

Definition at line 116 of file TreeBuilder.php.

116 : self
117 {
118 $this->setting = $setting;
119 return $this;
120 }

References ILIAS\Tree\TreeBuilder\$setting.

◆ withTreeId()

ILIAS\Tree\TreeBuilder::withTreeId ( int  $tree_id)

Set the tree identifier.

Parameters
int$tree_idTree identifier
Returns
$this

Definition at line 68 of file TreeBuilder.php.

68 : self
69 {
70 $this->tree_id = $tree_id;
71 return $this;
72 }

References ILIAS\Tree\TreeBuilder\$tree_id.

◆ withUser()

ILIAS\Tree\TreeBuilder::withUser ( \ilObjUser  $user)

Set the current user.

Parameters
\ilObjUser$userUser object
Returns
$this

Definition at line 164 of file TreeBuilder.php.

164 : self
165 {
166 $this->user = $user;
167 return $this;
168 }

References ILIAS\Tree\TreeBuilder\$user, and ILIAS\Repository\user().

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ILIAS\Tree\TreeBuilder::$db = null
private

◆ $event_handler

ilAppEventHandler ILIAS\Tree\TreeBuilder::$event_handler = null
private

Definition at line 46 of file TreeBuilder.php.

Referenced by ILIAS\Tree\TreeBuilder\withEventHandler().

◆ $language

Language ILIAS\Tree\TreeBuilder::$language = null
private

Definition at line 50 of file TreeBuilder.php.

Referenced by ILIAS\Tree\TreeBuilder\withLanguage().

◆ $logger

LoggerInterface ILIAS\Tree\TreeBuilder::$logger = null
private

Definition at line 44 of file TreeBuilder.php.

Referenced by ILIAS\Tree\TreeBuilder\withLogger().

◆ $obj_data_cache

ilObjectDataCache ILIAS\Tree\TreeBuilder::$obj_data_cache = null
private

Definition at line 47 of file TreeBuilder.php.

Referenced by ILIAS\Tree\TreeBuilder\withObjectDataCache().

◆ $obj_definition

ilObjectDefinition ILIAS\Tree\TreeBuilder::$obj_definition = null
private

Definition at line 48 of file TreeBuilder.php.

Referenced by ILIAS\Tree\TreeBuilder\withObjectDefinition().

◆ $root_id

int ILIAS\Tree\TreeBuilder::$root_id = 0
private

◆ $setting

Setting ILIAS\Tree\TreeBuilder::$setting = null
private

◆ $tree_id

int ILIAS\Tree\TreeBuilder::$tree_id
private

◆ $user

ilObjUser ILIAS\Tree\TreeBuilder::$user = null
private

Definition at line 49 of file TreeBuilder.php.

Referenced by ILIAS\Tree\TreeBuilder\withUser().


The documentation for this class was generated from the following file: