/** * Creates a new URL wildcard * * @throws \eZ\Publish\Core\REST\Server\Exceptions\ForbiddenException * @return \eZ\Publish\Core\REST\Server\Values\CreatedURLWildcard */ public function createURLWildcard() { $urlWildcardCreate = $this->inputDispatcher->parse(new Message(array('Content-Type' => $this->request->headers->get('Content-Type')), $this->request->getContent())); try { $createdURLWildcard = $this->urlWildcardService->create($urlWildcardCreate['sourceUrl'], $urlWildcardCreate['destinationUrl'], $urlWildcardCreate['forward']); } catch (InvalidArgumentException $e) { throw new ForbiddenException($e->getMessage()); } return new Values\CreatedURLWildcard(array('urlWildcard' => $createdURLWildcard)); }
/** * Creates a new url wildcard * * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the $sourceUrl pattern already exists * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to create url wildcards * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if the number of "*" patterns in $sourceUrl and * the number of {\d} placeholders in $destinationUrl doesn't match or * if the placeholders aren't a valid number sequence({1}/{2}/{3}), starting with 1. * * @param string $sourceUrl * @param string $destinationUrl * @param boolean $forward * * @return \eZ\Publish\API\Repository\Values\Content\UrlWildcard */ public function create($sourceUrl, $destinationUrl, $forward = false) { $returnValue = $this->service->create($sourceUrl, $destinationUrl, $forward); $this->signalDispatcher->emit(new CreateSignal(array('urlWildcardId' => $returnValue->id))); return $returnValue; }