PathDescription.php
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2020 wemove digital solutions GmbH
5  *
6  * Licensed under the terms of the MIT License.
7  *
8  * See the LICENSE file distributed with this work for
9  * additional information.
10  */
11 namespace wcmf\lib\persistence;
12 
13 /**
14  * PathDescription describes a path between two types.
15  *
16  * @author ingo herwig <ingo@wemove.com>
17  */
19 
20  protected $startType = '';
21  protected $startRole = '';
22  protected $endType = '';
23  protected $endRole = '';
24 
25  protected $path = null;
26 
27  /**
28  * Constructor.
29  * @param $path Array of RelationDescription instances
30  */
31  public function __construct(array $path) {
32  $this->path = $path;
33 
34  $pathSize = sizeof($path);
35  if ($pathSize > 0) {
36  $firstPathPart = $path[0];
37  $lastPathPart = $path[$pathSize-1];
38  $this->startType = $firstPathPart->getThisType();
39  $this->startRole = $firstPathPart->getThisRole();
40  $this->endType = $lastPathPart->getOtherType();
41  $this->endRole = $lastPathPart->getOtherRole();
42  }
43  }
44 
45  /**
46  * Get the PersistentObject type at the start point
47  * @return String
48  */
49  public function getStartType() {
50  return $this->startType;
51  }
52 
53  /**
54  * Get the role name at the start point
55  * @return String
56  */
57  public function getStartRole() {
58  return $this->startRole;
59  }
60 
61  /**
62  * Get the PersistentObject type at the end point
63  * @return String
64  */
65  public function getEndType() {
66  return $this->endType;
67  }
68 
69  /**
70  * Get the role name at the end point
71  * @return String
72  */
73  public function getEndRole() {
74  return $this->endRole;
75  }
76 
77  /**
78  * Get the path
79  * @return Array of RelationDesctription instances
80  */
81  public function getPath() {
82  return $this->path;
83  }
84 
85  /**
86  * Get the length of the path
87  * @return int
88  */
89  public function getPathLength() {
90  return sizeof($this->path);
91  }
92 }
93 ?>
getStartRole()
Get the role name at the start point.
getPathLength()
Get the length of the path.
getStartType()
Get the PersistentObject type at the start point.
Persistence layer related interfaces and classes.
Definition: namespaces.php:42
getEndRole()
Get the role name at the end point.
__construct(array $path)
Constructor.
getEndType()
Get the PersistentObject type at the end point.
PathDescription describes a path between two types.