ArangoDB-PHP API Documentation
  • Namespace
  • Class
  • Deprecated

Namespaces

  • triagens
    • ArangoDb

Classes

  • triagens\ArangoDb\AdminHandler
  • triagens\ArangoDb\AqlUserFunction
  • triagens\ArangoDb\Autoloader
  • triagens\ArangoDb\Batch
  • triagens\ArangoDb\BatchPart
  • triagens\ArangoDb\BindVars
  • triagens\ArangoDb\Collection
  • triagens\ArangoDb\CollectionHandler
  • triagens\ArangoDb\Connection
  • triagens\ArangoDb\ConnectionOptions
  • triagens\ArangoDb\Cursor
  • triagens\ArangoDb\Database
  • triagens\ArangoDb\DefaultValues
  • triagens\ArangoDb\Document
  • triagens\ArangoDb\DocumentHandler
  • triagens\ArangoDb\Edge
  • triagens\ArangoDb\EdgeDefinition
  • triagens\ArangoDb\EdgeHandler
  • triagens\ArangoDb\Endpoint
  • triagens\ArangoDb\Export
  • triagens\ArangoDb\ExportCursor
  • triagens\ArangoDb\Graph
  • triagens\ArangoDb\GraphHandler
  • triagens\ArangoDb\Handler
  • triagens\ArangoDb\HttpHelper
  • triagens\ArangoDb\HttpResponse
  • triagens\ArangoDb\QueryCacheHandler
  • triagens\ArangoDb\QueryHandler
  • triagens\ArangoDb\Statement
  • triagens\ArangoDb\TraceRequest
  • triagens\ArangoDb\TraceResponse
  • triagens\ArangoDb\Transaction
  • triagens\ArangoDb\Traversal
  • triagens\ArangoDb\UpdatePolicy
  • triagens\ArangoDb\UrlHelper
  • triagens\ArangoDb\Urls
  • triagens\ArangoDb\User
  • triagens\ArangoDb\UserHandler
  • triagens\ArangoDb\ValueValidator
  • triagens\ArangoDb\Vertex
  • triagens\ArangoDb\VertexHandler

Exceptions

  • triagens\ArangoDb\ClientException
  • triagens\ArangoDb\ConnectException
  • triagens\ArangoDb\Exception
  • triagens\ArangoDb\ServerException
  1 <?php
  2 
  3 /**
  4  * ArangoDB PHP client: single document
  5  *
  6  * @package   triagens\ArangoDb
  7  * @author    Florian Bartels
  8  * @copyright Copyright 2014, triagens GmbH, Cologne, Germany
  9  *
 10  * @since     2.2
 11  */
 12 
 13 namespace triagens\ArangoDb;
 14 
 15 /**
 16  * Value object representing an edge Definition.
 17  * An edge definition contains a collection called 'relation' to store the edges and
 18  * multiple vertices collection defined in 'fromCollections' and 'toCollections'.
 19  *
 20  * <br>
 21  *
 22  * @package   triagens\ArangoDb
 23  * @since     2.2
 24  */
 25 class EdgeDefinition
 26 {
 27     /**
 28      * The name of the edge collection for this relation.
 29      *
 30      * @var string name of the edge collection
 31      */
 32     protected $_relation;
 33 
 34     /**
 35      * An array containing the names of the vertices collections holding the start vertices.
 36      *
 37      * @var array names of the start vertices collection
 38      */
 39     protected $_fromCollections = [];
 40 
 41     /**
 42      * An array containing the names of the vertices collections holding the end vertices.
 43      *
 44      * @var array names of the end vertices collection
 45      */
 46     protected $_toCollections = [];
 47 
 48     /**
 49      * Constructs an new edge definition
 50      *
 51      * @param string       $relation        - name of the relation (the underlying edge collection).
 52      * @param array|string $fromCollections - a list of collections providing the edges start vertices or a string holding a single collection name.
 53      * @param array|string $toCollections   - a list of collections providing the edges end vertices or a string holding a single collection name.
 54      *
 55      * @since     2.2
 56      *
 57      */
 58     public function __construct($relation = null, $fromCollections = [], $toCollections = [])
 59     {
 60         $this->_relation = $relation;
 61 
 62         $fromCollections = (array) $fromCollections;
 63         $toCollections   = (array) $toCollections;
 64 
 65         $this->_fromCollections = $fromCollections;
 66         $this->_toCollections   = $toCollections;
 67     }
 68 
 69     /**
 70      * Set the relation of the edge definition
 71      *
 72      * @param string $relation - the name of the relation.
 73      *
 74      * @since     2.2
 75      */
 76     public function setRelation($relation)
 77     {
 78         $this->_relation = $relation;
 79     }
 80 
 81     /**
 82      * Get the relation of the edge definition.
 83      *
 84      * @return string
 85      * @since     2.2
 86      */
 87     public function getRelation()
 88     {
 89         return $this->_relation;
 90     }
 91 
 92 
 93     /**
 94      * Get the 'to' collections of the graph.
 95      *
 96      * @return array
 97      * @since     2.2
 98      */
 99     public function getToCollections()
100     {
101         return $this->_toCollections;
102     }
103 
104     /**
105      * Get the 'from' collections of the graph.
106      *
107      * @return array
108      * @since     2.2
109      */
110     public function getFromCollections()
111     {
112         return $this->_fromCollections;
113     }
114 
115     /**
116      * Add a 'to' collections of the graph.
117      *
118      * @param string $toCollection - the name of the added collection.
119      *
120      * @since     2.2
121      */
122     public function addToCollection($toCollection)
123     {
124         $this->_toCollections[] = $toCollection;
125     }
126 
127     /**
128      * Add a 'from' collections of the graph.
129      *
130      * @param string $fromCollection - the name of the added collection.
131      *
132      * @since     2.2
133      */
134     public function addFromCollection($fromCollection)
135     {
136         $this->_fromCollections[] = $fromCollection;
137     }
138 
139     /**
140      * Resets the 'to' collections of the graph.
141      *
142      * @since     2.2
143      */
144     public function clearToCollection()
145     {
146         $this->_toCollections = [];
147     }
148 
149     /**
150      * Resets the 'from' collections of the graph.
151      *
152      * @since     2.2
153      */
154     public function clearFromCollection()
155     {
156         return $this->_fromCollections = [];
157     }
158 
159     /**
160      * Transforms an edge definition to an array.
161      *
162      * @return array
163      * @since     2.2
164      */
165     public function transformToArray()
166     {
167         $transformedEd               = [];
168         $transformedEd['collection'] = $this->getRelation();
169         $transformedEd['from']       = $this->getFromCollections();
170         $transformedEd['to']         = $this->getToCollections();
171 
172         return $transformedEd;
173     }
174 
175 
176     /**
177      * Constructs an undirected relation. This relation is an edge definition where the edges can start and end
178      * in any vertex from the collection list.
179      *
180      * @param string $relation          - name of the relation (the underlying edge collection).
181      * @param array  $vertexCollections - a list of collections providing the edges start and end vertices.
182      *
183      * @return EdgeDefinition
184      * @since     2.2
185      */
186     public static function createUndirectedRelation($relation, $vertexCollections)
187     {
188         return new EdgeDefinition($relation, $vertexCollections, $vertexCollections);
189     }
190 
191 
192     /**
193      * Constructs a directed relation. This relation is an edge definition where the edges can start only in the
194      * vertices defined in 'fromCollections' and end in vertices defined in 'toCollections'.
195      *
196      * @param string       $relation        - name of the relation (the underlying edge collection).
197      * @param array|string $fromCollections - a list of collections providing the edges start vertices or a string holding a single collection name.
198      * @param array|string $toCollections   - a list of collections providing the edges end vertices or a string holding a single collection name.
199      *
200      * @return EdgeDefinition
201      * @since     2.2
202      */
203     public static function createDirectedRelation($relation, $fromCollections, $toCollections)
204     {
205         return new EdgeDefinition($relation, $fromCollections, $toCollections);
206     }
207 
208 }
209 
ArangoDB-PHP API Documentation API documentation generated by ApiGen