Provides a central management class for event handlers and common functionality for the connectable component.
More...
|
static | setDefaults () |
|
static | onInitialize () |
|
static | registerConnectable ($connectable, $targets) |
| Register a connectable class and the list of classes it can connect with. More...
|
|
static | getConnectableFromRequest () |
| Create and populate a Connectable DataItem based on its primary key as passed in on the requesting URL. More...
|
|
static | instantiate ($class, $id) |
| Safely instantiate a Connectable. More...
|
|
static | canConnect ($source, $target) |
| Determine whether two objects or classes can connect based on the registered connectable map. More...
|
|
static | connectionExists ($source, $target) |
| Check whether a connection exists between the given source and target objects. More...
|
|
static | addConnection ($source, $target) |
| Add a connection between the given source and target objects. More...
|
|
static | removeConnection ($source, $target) |
| Remove any connection that exists between the source and target object (including back-links if they were created). More...
|
|
static | removeConnections ($source, $targetClass) |
| Remove any connection that exists between the source and objects of the specified target class (including back-links if they were created). More...
|
|
static | removeAllConnections ($object) |
| Remove all the connections to and from the given object. More...
|
|
static | getTargetClasses ($sourceItem) |
| Return an array of connectable target classes for the specified item. More...
|
|
static | getConnectedItems ($sourceItem, $targetClass, $constraint="") |
| Returns the connected items for the specified source that are of the specified class. More...
|
|
static | getConnectedItemCount ($sourceItem, $targetClass, $constraint="") |
| Returns the number of connected items for the specified source that are of the specified class. More...
|
|
static | upgradeComponent ($version) |
|
Provides a central management class for event handlers and common functionality for the connectable component.
Definition at line 25 of file connectable_manager.inc.
◆ addConnection()
static ConnectableManager::addConnection |
( |
|
$source, |
|
|
|
$target |
|
) |
| |
|
static |
Add a connection between the given source and target objects.
If the target object registered itself as connectable to the source object, then a back-link is automatically inserted.
- Parameters
-
DataItem | $source | the source object |
DataItem | $target | the target object |
Definition at line 144 of file connectable_manager.inc.
151 $sourceClass = get_class(
$source);
152 $targetClass = get_class(
$target);
154 if (!$sourceDefn || !$targetDefn)
156 throw new FakoliException(
"Attempt to link an object that is not a registered Connectable");
161 throw new FakoliException(
"Cannot create a link between a $sourceClass and a $targetClass");
165 $record->source_class = $sourceClass;
167 $record->target_class = $targetClass;
176 $record->source_class = $sourceClass;
178 $record->target_class = $targetClass;
static canConnect($source, $target)
Determine whether two objects or classes can connect based on the registered connectable map.
static $connectables
Connectable type map defining which items can be connected together.
static connectionExists($source, $target)
Check whether a connection exists between the given source and target objects.
FakoliException is the base exception class for all Fakoli errors.
◆ canConnect()
static ConnectableManager::canConnect |
( |
|
$source, |
|
|
|
$target |
|
) |
| |
|
static |
Determine whether two objects or classes can connect based on the registered connectable map.
- Parameters
-
mixed | $source | either a Connectable DataItem or its class name |
mixed | $target | either a Connectable DataItem or its class name |
- Returns
- boolean true if the items can be connected, false otherwise
Definition at line 107 of file connectable_manager.inc.
116 if ($t ==
$target)
return true;
static getTargetClasses($sourceItem)
Return an array of connectable target classes for the specified item.
◆ ConnectableManager()
ConnectableManager::ConnectableManager |
( |
| ) |
|
◆ connectionExists()
static ConnectableManager::connectionExists |
( |
|
$source, |
|
|
|
$target |
|
) |
| |
|
static |
Check whether a connection exists between the given source and target objects.
- Parameters
-
DataItem | $source | the source object |
DataItem | $target | the target object |
Definition at line 127 of file connectable_manager.inc.
129 return Query::create(
ConnectionRecord,
"WHERE source_class=:sc AND source_id=:si AND target_class=:tc AND target_id=:ti")
130 ->bind(
":sc", get_class(
$source),
◆ getConnectableFromRequest()
static ConnectableManager::getConnectableFromRequest |
( |
| ) |
|
|
static |
Create and populate a Connectable DataItem based on its primary key as passed in on the requesting URL.
- Returns
- Connectable
Definition at line 63 of file connectable_manager.inc.
67 if (array_key_exists($primaryKey, $_GET))
69 $id = checkNumeric($_GET[$primaryKey]);
static $classLookup
Look-up table of connectable classes from their primary keys.
◆ getConnectedItemCount()
static ConnectableManager::getConnectedItemCount |
( |
|
$sourceItem, |
|
|
|
$targetClass, |
|
|
|
$constraint = "" |
|
) |
| |
|
static |
Returns the number of connected items for the specified source that are of the specified class.
- Parameters
-
Connectable | $sourceItem | the source DataItem (must implement the Connectable interface) |
string | $targetClass | The class of DataItem Connectable objects that are to be returned |
string | $constraint | additional constraints to be applied |
- Exceptions
-
Definition at line 278 of file connectable_manager.inc.
280 $query = ConnectableManager::generateConnectedQuery($sourceItem, $targetClass,
$constraint);
281 return Query::create($targetClass, $query)
282 ->bind(
":sc", get_class($sourceItem),
":si", $sourceItem->get($sourceItem->getPrimaryKey()),
":tc", $targetClass)
283 ->executeValue(
"COUNT(1)");
◆ getConnectedItems()
static ConnectableManager::getConnectedItems |
( |
|
$sourceItem, |
|
|
|
$targetClass, |
|
|
|
$constraint = "" |
|
) |
| |
|
static |
Returns the connected items for the specified source that are of the specified class.
- Parameters
-
Connectable | $sourceItem | the source DataItem (must implement the Connectable interface) |
string | $targetClass | The class of DataItem Connectable objects that are to be returned |
string | $constraint | additional constraints to be applied |
- Exceptions
-
Definition at line 262 of file connectable_manager.inc.
264 $query = ConnectableManager::generateConnectedQuery($sourceItem, $targetClass,
$constraint);
265 return Query::create($targetClass, $query)
266 ->bind(
":sc", get_class($sourceItem),
":si", $sourceItem->get($sourceItem->getPrimaryKey()),
":tc", $targetClass)
◆ getTargetClasses()
static ConnectableManager::getTargetClasses |
( |
|
$sourceItem | ) |
|
|
static |
Return an array of connectable target classes for the specified item.
- Parameters
-
- Returns
- Array of class names
- Exceptions
-
Definition at line 240 of file connectable_manager.inc.
242 $sourceClass = is_object($sourceItem) ? get_class($sourceItem) : $sourceItem;
246 throw new FakoliException(
"$sourceClass is not a registered connectable class");
◆ instantiate()
static ConnectableManager::instantiate |
( |
|
$class, |
|
|
|
$id |
|
) |
| |
|
static |
◆ onInitialize()
static ConnectableManager::onInitialize |
( |
| ) |
|
|
static |
Definition at line 41 of file connectable_manager.inc.
static fireEvent($event, $parameter=null, $mustBeConsumed=false)
Fire an event to all subscribers as detailed in their manifests.
◆ registerConnectable()
static ConnectableManager::registerConnectable |
( |
|
$connectable, |
|
|
|
$targets |
|
) |
| |
|
static |
Register a connectable class and the list of classes it can connect with.
- Parameters
-
string | $connectable | the connectable class |
array | $targets | array of target classes to which it can be connected |
Definition at line 51 of file connectable_manager.inc.
54 $obj =
new $connectable;
◆ removeAllConnections()
static ConnectableManager::removeAllConnections |
( |
|
$object | ) |
|
|
static |
Remove all the connections to and from the given object.
Use this method when the object is being deleted from the database to ensure that you don't end up with stale connections.
- Parameters
-
DataItem | $object | the object for which connections are to be removed |
Definition at line 226 of file connectable_manager.inc.
229 $objectID = $object->get($object->getPrimaryKey());
230 $class = get_class($object);
231 $record->delete(
"WHERE (source_class='{$class}' AND source_id={$objectID}) OR (target_class='{$class}' AND target_id={$objectID})");
◆ removeConnection()
static ConnectableManager::removeConnection |
( |
|
$source, |
|
|
|
$target |
|
) |
| |
|
static |
Remove any connection that exists between the source and target object (including back-links if they were created).
- Parameters
-
DataItem | $source | the source object |
DataItem | $target | the target object |
Definition at line 191 of file connectable_manager.inc.
197 $sourceClass = get_class(
$source);
198 $targetClass = get_class(
$target);
200 $record->delete(
"WHERE (source_class='{$sourceClass}' AND source_id={$sourceID} AND target_class='{$targetClass}' AND target_id={$targetID}') " .
201 "OR (source_class='{$targetClass}' AND source_id={$targetID} AND target_class='{$sourceClass}' AND target_id={$sourceID})");
◆ removeConnections()
static ConnectableManager::removeConnections |
( |
|
$source, |
|
|
|
$targetClass |
|
) |
| |
|
static |
Remove any connection that exists between the source and objects of the specified target class (including back-links if they were created).
- Parameters
-
DataItem | $source | the source object |
DataItem | $targetClass | the target class |
Definition at line 210 of file connectable_manager.inc.
213 $sourceClass = get_class(
$source);
216 $record->delete(
"WHERE (source_class='{$sourceClass}' AND source_id={$sourceID} AND target_class='{$targetClass}') " .
217 "OR (source_class='{$targetClass}' AND target_class='{$sourceClass}' AND target_id={$sourceID})");
◆ setDefaults()
static ConnectableManager::setDefaults |
( |
| ) |
|
|
static |
◆ upgradeComponent()
static ConnectableManager::upgradeComponent |
( |
|
$version | ) |
|
|
static |
◆ $classLookup
ConnectableManager::$classLookup = array() |
|
static |
◆ $connectables
ConnectableManager::$connectables = array() |
|
static |
◆ $contextRouter
ConnectableManager::$contextRouter = "" |
|
static |
The documentation for this class was generated from the following file: