<?php

final class SemiStructuredObjectNewInstanceController
  extends SemiStructuredObjectTypeController {

    public function handleRequest(AphrontRequest $request) {
      $viewer = $request->getViewer();
      $id = $request->getURIData('typeid');

      $object_type = id(new SemiStructuredObjectTypeQuery())
        ->setViewer($viewer)
        ->withIDs(array($id))
        ->executeOne();
      if (!$object_type) {
        return new Aphront404Response();
      }

      $this->setObjectType($object_type);

      return id(new SemiStructuredObjectInstanceEditEngine())
        ->setObjectType($object_type)
        ->setController($this)
        ->buildResponse();
  }
}
