|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Cycle\ORM\Select; |
|
6
|
|
|
|
|
7
|
|
|
use Cycle\ORM\FactoryInterface; |
|
8
|
|
|
use Cycle\ORM\Parser\AbstractNode; |
|
9
|
|
|
use Cycle\ORM\Parser\StaticNode; |
|
10
|
|
|
use Cycle\ORM\Service\SourceProviderInterface; |
|
11
|
|
|
use Cycle\ORM\SchemaInterface; |
|
12
|
|
|
use Cycle\ORM\Select\Traits\ColumnsTrait; |
|
13
|
|
|
use Cycle\ORM\Select\Traits\ScopeTrait; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @internal |
|
17
|
|
|
*/ |
|
18
|
|
|
final class UpdateLoader extends AbstractLoader |
|
19
|
|
|
{ |
|
20
|
|
|
use ColumnsTrait; |
|
21
|
|
|
use ScopeTrait; |
|
22
|
|
|
|
|
23
|
|
|
protected array $options = [ |
|
24
|
|
|
'load' => true, |
|
25
|
|
|
'scope' => true, |
|
26
|
|
|
]; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @param non-empty-string $target Entity role or alias. |
|
|
|
|
|
|
30
|
|
|
*/ |
|
31
|
|
|
public function __construct( |
|
32
|
|
|
SchemaInterface $ormSchema, |
|
33
|
|
|
SourceProviderInterface $sourceProvider, |
|
34
|
|
|
FactoryInterface $factory, |
|
35
|
|
|
string $target, |
|
36
|
|
|
) { |
|
37
|
|
|
parent::__construct($ormSchema, $sourceProvider, $factory, $target); |
|
38
|
|
|
$this->columns = $this->normalizeColumns($this->define(SchemaInterface::COLUMNS)); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function getAlias(): string |
|
42
|
|
|
{ |
|
43
|
|
|
return $this->target; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function loadData(AbstractNode $node, bool $includeRole = false): void |
|
47
|
|
|
{ |
|
48
|
|
|
// loading child datasets |
|
49
|
|
|
foreach ($this->load as $relation => $loader) { |
|
50
|
|
|
$loader->loadData($node->getNode($relation), $includeRole); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
// $this->loadHierarchy($node, $includeRole); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function isLoaded(): bool |
|
57
|
|
|
{ |
|
58
|
|
|
return true; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
protected function initNode(): StaticNode |
|
62
|
|
|
{ |
|
63
|
|
|
return new StaticNode($this->columnNames(), (array) $this->define(SchemaInterface::PRIMARY_KEY)); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|