/** * Code executed when command invoked. * * @param InputInterface $input * @param OutputInterface $output */ protected function execute(InputInterface $input, OutputInterface $output) { foreach ($this->classes as $className) { $output->write('Generating "<info>' . $className . '</info>" '); $this->hydratorFactory->getHydratorClassName($className); $output->writeLn('<comment>Done</comment>'); } }
/** * Code executed when command invoked. * * @param InputInterface $input * @param OutputInterface $output */ protected function execute(InputInterface $input, OutputInterface $output) { $proxyPath = $input->getArgument('cache-path'); $className = $input->getArgument('class'); $hydratorFactory = new HydratorFactory($proxyPath); $output->write('Generating "<info>' . $className . '</info>" '); $hydratorFactory->getHydratorClassName($className); $output->writeLn('<comment>Done</comment>'); }
/** * @param array $serializedObject * * @return object */ private function deserializeObject(array $serializedObject) { list($name, $payload) = $this->dataFormatter->getNameAndPayload($serializedObject); $curatedPayload = []; foreach ($payload as $key => $value) { $curatedPayload[$key] = $this->recursiveDeserialize($value); } $objectFqcn = $this->classMapper->getClassName($name); foreach ($this->customSerializers as $customSerializer) { if ($customSerializer->canHandle($objectFqcn)) { return $customSerializer->deserialize($curatedPayload, $objectFqcn); } } $object = $this->instantiator->instantiate($objectFqcn); return $this->hydratorFactory->getHydrator($objectFqcn)->hydrate($curatedPayload, $object); }
/** * @test */ public function itShouldReturnAnHydratorInstance() { $hydratorFactory = new HydratorFactory(__DIR__ . DIRECTORY_SEPARATOR . 'cache', true); $hydrator = $hydratorFactory->getHydrator(Serializable::class); $this->assertInstanceOf(HydratorInterface::class, $hydrator); }