public function execute(CommandInterface $command) { switch ($command->getName()) { case CommandInterface::COMMAND_FIND: $criteria = $command->getParams("criteria", []); $limit = $command->getParams("limit", null); $offset = $command->getParams("offset", null); $order = $command->getParams("order", null); return $this->find($criteria, $limit, $offset, $order); case CommandInterface::COMMAND_GET: $id = $command->getParams("id"); return $this->get($id); case CommandInterface::COMMAND_COUNT: $criteria = $command->getParams("criteria", []); return $this->count($criteria); case CommandInterface::COMMAND_SAVE: /** @var EntityInterface $entity */ $entity = $command->getParams("entity"); $isExisting = $entity->isExistingEntity(); $data = $command->getParams("data"); return $this->save($data, $isExisting); case CommandInterface::COMMAND_DELETE: $id = $command->getParams("id"); return $this->delete($id); case CommandInterface::COMMAND_LOAD: return $this->load($command->getParams("entity"), $command->getParams("data")); case CommandInterface::COMMAND_RESERVE: return $this->reserve($command->getParams("entity")); case GenerateIdCommandInterface::COMMAND_GENERATE_ID: return $this->genId($command->getParams("tableId")); default: throw new \InvalidArgumentException("Command type \" {$command->getName()} not supported"); } }
public function execute(CommandInterface $command) { if ($command->getName() !== CommandInterface::COMMAND_CREATE) { throw new \InvalidArgumentException("Command type \" {$command->getName()} not supported"); } return $this->create($command->getClass(), $command->getParams()); }
public function getId(CommandInterface $command) { $entity = $command->getParams("entity"); if (is_object($entity)) { if ($entity instanceof EntityInterface) { return $entity->getId(); } else { throw new \InvalidArgumentException("entity object not instance of EntityInterface"); } } return $entity; }
public function execute(CommandInterface $command) { switch ($command->getName()) { case RelationLoadCommand::COMMAND_RELATION_LOAD: return $this->getLinked($command->getParams("entity")); break; case RelationParamsCommand::COMMAND_RELATION_PARAMS: return $this->getParam($command->getParams("param"), $command->getParams()); default: return parent::execute($command); } }