/** * Merges the passed configuration into this one. Configuration values * of the passed configuration will overwrite the this one. * * @param \AppserverIo\Routlt\Description\ResultDescriptorInterface $resultDescriptor The configuration to merge * * @return void * @throws \AppserverIo\Routlt\Description\DescriptorException Is thrown if the passed descriptor has a different method name */ public function merge(ResultDescriptorInterface $resultDescriptor) { // check if the classes are equal if ($this->getName() !== $resultDescriptor->getName()) { throw new DescriptorException(sprintf('You try to merge a result configuration for % with %s', $resultDescriptor->getName(), $this->getName())); } // merge the type if ($type = $resultDescriptor->getType()) { $this->setType($type); } // merge the result if ($result = $resultDescriptor->getResult()) { $this->setResult($result); } }
/** * Initializes the instance with the configured result value. * * @param \AppserverIo\Routlt\Results\ResultDescriptorInterface $resultDescriptor The result descriptor instance */ public function __construct(ResultDescriptorInterface $resultDescriptor) { $this->name = $resultDescriptor->getName(); $this->type = $resultDescriptor->getType(); $this->result = $resultDescriptor->getResult(); }
/** * Creates a new instance of the action result the passed descriptor. * * @param \AppserverIo\Routlt\Description\ResultDescriptorInterface $resultDescriptor The action result descriptor * * @return \AppserverIo\Routlt\ActionInterface The action instance */ public function newResultInstance(ResultDescriptorInterface $resultDescriptor) { // load the class name $className = $resultDescriptor->getType(); // create a new instance of the result $result = new $className($resultDescriptor); // if the result is servlet context aware if ($result instanceof ServletContextAware) { $result->setServletContext($this->getServletContext()); } // return the instance return $result; }