Beispiel #1
0
 /**
  * @param \Nette\Forms\Container|\NForms\IContainer $container
  * @param                                           $object
  * @throws \NForms\Exceptions\InvalidStateException
  * @throws \NForms\Exceptions\InvalidArgumentException
  * @throws \NForms\Exceptions\UnexpectedTypeException
  * @return \NForms\Metadata\IClassMetadata
  */
 private function getMetadata(Container $container, $object)
 {
     if (!is_object($object)) {
         throw new InvalidArgumentException("Expected object, given '" . gettype($object) . "'");
     }
     if ($container instanceof IContainer) {
         if ($container->getClassName() === NULL) {
             throw new InvalidStateException("Container '{$container->getName()}' has no class.");
         }
         if (!is_a($object, $container->getClassName())) {
             throw new UnexpectedTypeException("Class mismatch. Container is for '{$container->getClassName()}' class, but object is '" . get_class($object) . "'.");
         }
         $className = $container->getClassName();
     } else {
         $className = get_class($object);
     }
     return $this->metadataFactory->getMetadataFor($className);
 }