/** * {@inheritdoc} */ public function setOrigin(OriginAwareInterface $originAware, $origin) { if (!is_object($origin)) { throw new UnexpectedTypeException($origin, 'object'); } /** @var \DoS\ResourceBundle\Model\OriginAwareInterface $originAware */ if ($origin instanceof OriginContextInterface) { $originAware->setOriginAlias($origin->getOriginalAlias()); $originAware->setOriginType($origin->getOriginalType()); $originAware->setOriginId($origin->getId()); return; } if (null === ($id = $this->accessor->getValue($origin, $this->identifier))) { throw new \InvalidArgumentException(sprintf('Origin %s is not set.', $this->identifier)); } $originAware->setOriginId($id); $originAware->setOriginType(get_class($origin)); }
/** * {@inheritdoc} */ public function setOrigin(OriginAwareInterface $originAware, $origin) { if (!is_object($origin)) { throw new UnexpectedTypeException($origin, 'object'); } if (null === ($id = $this->accessor->getValue($origin, $this->identifier))) { throw new \InvalidArgumentException(sprintf('Origin %s is not set.', $this->identifier)); } $originAware->setOriginId($id); $originAware->setOriginType(get_class($origin)); }