Example #1
0
 /**
  * Set all children (outgoing) of the node
  * 
  * This disconnects all current children of the node, and then connects
  * the node to the given array (turned RestrictedSet).
  * 
  * @see connectIncoming()
  * 
  * @param array (of Falcraft\Data\Types\Resource\VertexInterface) of new parents
  * 
  */
 public function setOutgoing(array $outgoing = array())
 {
     $outgoing = RestrictedSet::build($outgoing, $this->restrictions, array('strict' => true));
     Set::map(array($this, 'disconnectOutgoing'), $this->outgoing);
     foreach ($this->outgoing->iterate() as $vertex) {
         $vertex->disconnectIncoming($this);
     }
     Set::map(array($this, 'connectOutgoing'), $outgoing);
     foreach ($outgoing->iterate() as $vertex) {
         $vertex->connectIncoming($this);
     }
 }
Example #2
0
 public function setEventStateObject(AbstractEvent $state, $morph = true)
 {
     if (!$state instanceof AbstractEvent) {
         throw new Exception\InvalidArgumentException('AbstractEvent->setStateObject: ' . 'state not instance of AbstractEvent');
     } else {
         if ($morph) {
             $this->tags->clear();
             $this->categories->clear();
             $this->target = null;
             $this->data = null;
             $this->class = '';
             $this->function = '';
             $this->namespace = '';
         }
         $this->identifier = $state->getIdentifier();
         $this->{$field} = new Types\Set(Types\Set::union($state->getTags(), $this->{$field}), array('strict' => true));
         $this->categories = new Types\Set(Types\Set::union($state->getCategories(), $this->{$field}), array('strict' => true));
         $this->target = $state->getTarget();
         $this->data = $state->getData();
         $this->class = $state->getClass();
         $this->function = $state->getFunction();
         $this->namespace = $state->getNamespace();
     }
 }
Example #3
0
} catch (\Exception $e) {
    echo "EXCEPTION CAUGHT\n";
}
echo "Is Set 1 Empty? ";
try {
    if ($testSet->isEmpty()) {
        echo "Yes\n";
    } else {
        echo "No\n";
    }
} catch (\Exception $e) {
    echo "EXCEPTION CAUGHT\n";
}
echo "Is Set 2 Empty? ";
try {
    $testSet2 = new Types\Set();
    if ($testSet2->isEmpty()) {
        echo "Yes\n";
    } else {
        echo "No\n";
    }
} catch (\Exception $e) {
    echo "EXCEPTION CAUGHT\n";
}
echo "Size of Set 1 -> ";
$success = true;
$count = null;
try {
    $count = $testSet->size();
} catch (\Exception $e) {
    $success = false;
Example #4
0
 /**
  * Add a value to the set as a reference
  * 
  * Runs the value by the restrictions, only triggering if set is strict
  * otherwise doing nothing and exiting the function
  * 
  * @param mixed $value Value to add to the set, must be of allowed type
  * 
  * @return string|false The datum identifier, false otherwise
  * 
  * @throws Exception\InvalidArgumentException if 'strict' option is set
  *             and type is not in Restrictions
  * 
  */
 public function addReference(&$value)
 {
     try {
         $valid = Restrictions::checkElements(array($value), $this->restrictions, $this->conf->strict);
     } catch (Exception\InvalidArgumentException $e) {
         if ($this->conf->strict) {
             throw new Exception\InvalidArgumentException('RestrictedSet->addReference: Restricted Value');
         } else {
             return false;
         }
     }
     // Passes restrictions, but safety check
     if ($valid) {
         return parent::addReference($value);
     }
 }
Example #5
0
 /**
  * See if an event matches the filter exactly
  * 
  * If one thing doesn't match between the event and the filter
  * then we return false, instead of only one thing matching
  * 
  * @param Falcraft\Event\Resource\AbstractEvent $event
  *      The event to compare
  * 
  * @return bool
  * 
  */
 public function isStrictlyApplicable(EventResource\AbstractEvent $event, $includeIdentifier = false)
 {
     if ($includeIdentifier) {
         if ($this->identifier != $event->getIdentifier()) {
             return false;
         }
     }
     if ($this->target != $event->getTarget() || $this->function != $event->getFunction() || $this->class != $event->getClass() || $this->namespace != $event->getNamespace() || !Types\Set::subset($event->getTagsObject(), $this->tags) || !Types\Set::subset($event->getCategoriesObject(), $this->categories)) {
         return false;
     }
     return true;
 }
Example #6
0
 /**
  * Set all children (outgoing) of the node
  * 
  * This disconnects all current children of the node, and then connects
  * the node to the given array (turned RestrictedSet).
  * 
  * @see connectIncoming()
  * 
  * @param array (of Falcraft\Data\Types\Resource\VertexInterface) of new parents
  * 
  */
 public function setOutgoing(array $outgoing = array())
 {
     /* $outgoing = RestrictedSet::build($outgoing->,
        $this->restrictions, array( 'strict' => true )); */
     Set::map(array($this, 'disconnectOutgoing'), new Set($this->outgoing->getVerticesAsArray(), array('strict' => true)));
     foreach ($this->outgoing->getVerticesAsArray() as $vertex) {
         $vertex->disconnectIncoming($this);
     }
     Set::map(array($this, 'connectOutgoing'), new Set($outgoing, array('strict' => true)));
     foreach ($outgoing as $vertex) {
         $vertex->connectIncoming($this);
     }
     $outgoing = new VertexList($outgoing);
 }