/** * @param array $descriptors * @param array $options * @param Configuration $Configuration * * @return \Protobuf\Compiler\Context */ protected function createContext(array $descriptors, array $options = [], Configuration $config = null) { $cfg = $config ?: $this->config; $opts = Options::fromArray($options); $request = new CodeGeneratorRequest(); foreach ($descriptors as $item) { if (is_array($item)) { $name = $item['name']; $values = $item['values']; $package = $item['package']; $item = $this->createFileDescriptorProto($name, $package, $values); } $request->addProtoFile($item); $request->addFileToGenerate($item->getName()); } $builder = new EntityBuilder($request); $entities = $builder->buildEntities(); $context = new Context($entities, $opts, $cfg); return $context; }
/** * @param \google\protobuf\compiler\CodeGeneratorRequest $request * * @return \Protobuf\Compiler\Options */ protected function createOptions(CodeGeneratorRequest $request) { $parameter = $request->getParameter(); $options = []; parse_str($parameter, $options); return Options::fromArray($options); }
public function testDefaults() { $options = Options::fromArray([]); $this->assertFalse($options->getVerbose()); $this->assertFalse($options->getGenerateImported()); }