ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
06-to-new-object.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
7 function toNewObject()
8 {
9  class SomeClass
10  {
11  private $firstParameter;
12  private $secondParameter;
13  private $thirdParameter;
14 
15  public function __construct(
16  string $firstParameter,
17  int $secondParameter,
18  string $thirdParameter
19  ) {
20  $this->firstParameter = $firstParameter;
21  $this->secondParameter = $secondParameter;
22  $this->thirdParameter = $thirdParameter;
23  }
24 
25  public function say()
26  {
27  return $this->firstParameter;
28  }
29  }
30 
31  global $DIC;
32 
33  $refinery = $DIC->refinery();
34 
35  $transformation = $refinery->to()->toNew(
36  'SomeClass'
37  );
38 
39  $result = $transformation->transform(array('firstParameter', 2, 'thirdParameter'));
40 
41  return assert('firstParameter' === $result->say());
42 }
$result
toNewObject()
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)