/** * @param \stdClass $object * @return \sspmod_janus_Entity * @throws \RuntimeException */ protected function getEntityForObject($object) { if (!$object) { return null; } // JMSAopBundle gives us a MethodInvocation proxy when we secure a controller action. // Cute, but we don't need it. if ($object instanceof MethodInvocation) { return null; } if ($object instanceof \sspmod_janus_Entity) { return $object; } if ($object instanceof Revision) { $entityId = $object->getConnection()->getId(); $entityController = $this->getEntityControllerForEntityId($entityId); return $entityController->getEntity(); } throw new \RuntimeException('Unknown object to vote on?'); }