/
Association.php
36 lines (27 loc) · 1.24 KB
/
Association.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
namespace Concrete\Core\Export\Item\Express;
use Concrete\Core\Database\Connection\Connection;
use Concrete\Core\Export\Item\ItemInterface;
use Concrete\Core\Export\ExportableInterface;
defined('C5_EXECUTE') or die("Access Denied.");
class Association implements ItemInterface
{
/**
* @param $association \Concrete\Core\Entity\Express\Association
* @param \SimpleXMLElement $xml
*/
public function export($association, \SimpleXMLElement $xml)
{
$node = $xml->addChild('association');
// turns fully qualified class name into one_to_many
$class = substr(get_class($association), strrpos(get_class($association), '\\') + 1);
$type = uncamelcase(substr($class, 0, strpos($class, 'Association')));
$node->addAttribute('type', $type);
$node->addAttribute('id', $association->getID());
$node->addAttribute('source-entity', $association->getSourceEntity()->getID());
$node->addAttribute('target-entity', $association->getTargetEntity()->getID());
$node->addAttribute('target-property-name', $association->getTargetPropertyName());
$node->addAttribute('inversed-by-property-name', $association->getInversedByPropertyName());
return $node;
}
}