ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
06-to-new-object.php File Reference

Go to the source code of this file.

Functions

 toNewObject ()
 This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...
 

Function Documentation

◆ toNewObject()

toNewObject ( )

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Definition at line 21 of file 06-to-new-object.php.

References $DIC, ILIAS\Repository\$refinery, and ILIAS\GlobalScreen\Provider\__construct().

21  : bool
22 {
23  class SomeOtherClass
24  {
25  private string $firstParameter;
26  private int $secondParameter;
27  private string $thirdParameter;
28 
29  public function __construct(
30  string $firstParameter,
31  int $secondParameter,
32  string $thirdParameter
33  ) {
34  $this->firstParameter = $firstParameter;
35  $this->secondParameter = $secondParameter;
36  $this->thirdParameter = $thirdParameter;
37  }
38 
39  public function say(): string
40  {
41  return $this->firstParameter;
42  }
43 
44  public function getFirstParameter(): string
45  {
46  return $this->firstParameter;
47  }
48 
49  public function getSecodParameter(): int
50  {
51  return $this->secondParameter;
52  }
53 
54  public function getThirdParameter(): string
55  {
56  return $this->thirdParameter;
57  }
58  }
59 
60  global $DIC;
61 
62  $refinery = $DIC->refinery();
63 
64  $transformation = $refinery->to()->toNew(SomeOtherClass::class);
65 
66  $result = $transformation->transform(['firstParameter', 2, 'thirdParameter']);
67 
68  return assert('firstParameter' === $result->getFirstParameter());
69 }
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
Refinery Factory $refinery
+ Here is the call graph for this function: