protected function connectToMiddleware($uuid) { try { $this->openController(); $entity = EntityController::factory($this->em, $uuid); $class = $entity->getDefinition()->getInterpreter(); $interpreter = new $class($entity, $this->em, null, null); return $interpreter; } catch (\Exception $e) { echo "Trying to subcribe to invalid topic " . $uuid . "\n"; throw $e; } }
/** * Delete tuples from single or multiple channels * * @todo deduplicate Model\Channel code * @param string|array uuid */ public function delete($uuids) { $from = null; $to = null; // parse interval if (null !== ($from = $this->getParameters()->get('from'))) { $from = Interpreter::parseDateTimeString($from); if (null !== ($to = $this->getParameters()->get('to'))) { $to = Interpreter::parseDateTimeString($to); if ($from > $to) { throw new \Exception('From is larger than to'); } } } elseif ($from = $this->getParameters()->get('ts')) { $to = $from; } else { throw new \Exception('Missing timestamp (ts, from, to)'); } $rows = 0; foreach (self::makeArray($uuids) as $uuid) { $channel = EntityController::factory($this->em, $uuid, true); $rows += $channel->clearData($this->em->getConnection(), $from, $to); } return array('rows' => $rows); }
/** * Delete Aggregator or remove entity from aggregator */ public function delete($identifier) { if (!isset($identifier)) { return; } $aggregator = NULL; if ($uuids = self::makeArray($this->getParameters()->get('uuid'))) { // remove entity from aggregator $aggregator = $this->get($identifier); foreach ($uuids as $uuid) { $aggregator->removeChild(EntityController::factory($this->em, $uuid)); } $this->em->flush(); } else { // remove aggregator parent::delete($identifier); } return $aggregator; }