public function postInsert(ConnectionInterface $con = null) { if (null !== $this->getRedirected()) { //check if rewriting url alredy exists and put redirect to the new one RewritingUrlQuery::create()->filterByView($this->getView())->filterByViewId($this->getViewId())->filterByViewLocale($this->getViewLocale())->filterByRedirected($this->getId(), Criteria::NOT_IN)->update(array("Redirected" => $this->getId())); } }
protected function setSitemapProductImages(&$sitemap, $locale) { // Change timeout for this script ini_set('max_execution_time', Sitemap::getConfigValue('timeout', 30)); // Prepare query - get products URL $query = RewritingUrlQuery::create()->filterByView('product')->filterByRedirected(null)->filterByViewLocale($locale); // Join with visible products self::addJoinProductI18n($query); // Get products title & image file name $query->withColumn(ProductI18nTableMap::TITLE, 'PRODUCT_TITLE'); $query->addDescendingOrderByColumn(ProductImageTableMap::POSITION); $query->addGroupByColumn(RewritingUrlTableMap::VIEW_ID); $query->withColumn(ProductImageTableMap::FILE, 'PRODUCT_FILE'); // Execute query $results = $query->find(); // Get image generation configuration values $configValues = []; $configValues['width'] = Sitemap::getConfigValue('width'); $configValues['height'] = Sitemap::getConfigValue('height'); $configValues['quality'] = Sitemap::getConfigValue('quality', 75); $configValues['rotation'] = Sitemap::getConfigValue('rotation', 0); $configValues['resizeMode'] = Sitemap::getConfigValue('resize_mode', \Thelia\Action\Image::EXACT_RATIO_WITH_BORDERS); $configValues['bgColor'] = Sitemap::getConfigValue('background_color'); $configValues['allowZoom'] = Sitemap::getConfigValue('allow_zoom', false); // For each result, hydrate XML file /** @var RewritingUrl $result */ foreach ($results as $result) { // Generate image data $this->generateSitemapImage('product', $result, $configValues, $sitemap); } }
/** * @param RewriteUrlEvent $event * @throws \Exception * @throws \Propel\Runtime\Exception\PropelException */ public function setDefaultRewrite(RewriteUrlEvent $event) { $rewritingUrl = $event->getRewritingUrl(); //redirect all url to the new one RewritingUrlQuery::create()->filterByView($rewritingUrl->getView())->filterByViewId($rewritingUrl->getViewId())->filterByViewLocale($rewritingUrl->getViewLocale())->update(array("Redirected" => $rewritingUrl->getId())); //Re set new url to default $rewritingUrl->setRedirected(null); $rewritingUrl->save(); }
/** * @param string $currentVersion * @param string $newVersion * @param ConnectionInterface $con * @throws \Exception * @throws \Propel\Runtime\Exception\PropelException * @since 1.2.3 */ public function update($currentVersion, $newVersion, ConnectionInterface $con = null) { /* * Fix for urls that redirect on itself */ $urls = RewritingUrlQuery::create()->where(RewritingUrlTableMap::ID . " = " . RewritingUrlTableMap::REDIRECTED)->find(); /** @var RewritingUrl $url */ foreach ($urls as $url) { $parent = RewritingUrlQuery::create()->filterByView($url->getView())->filterByViewId($url->getViewId())->filterByViewLocale($url->getViewLocale())->filterByRedirected(null)->findOne(); $url->setRedirected($parent === null ? null : $parent->getId())->save(); } }
public function preImport() { // Empty address, customer and customer title table OrderQuery::create()->deleteAll(); AddressQuery::create()->deleteAll(); OrderAddressQuery::create()->deleteAll(); CustomerQuery::create()->deleteAll(); // Also empty url rewriting table $con = Propel::getConnection(RewritingUrlTableMap::DATABASE_NAME); $con->exec('SET FOREIGN_KEY_CHECKS=0'); RewritingUrlQuery::create()->deleteAll(); $con->exec('SET FOREIGN_KEY_CHECKS=1'); $this->cust_corresp->reset(); if ($this->thelia_version > 150) { $this->importCustomerTitle(); } }
/** * @param $view * @param $viewLocale * @param $viewId * @param $viewOtherParameters * * @return null|RewritingUrl */ public function getSpecificUrlQuery($view, $viewLocale, $viewId, $viewOtherParameters) { $urlQuery = RewritingUrlQuery::create()->joinRewritingArgument('ra', Criteria::LEFT_JOIN)->withColumn('`ra`.REWRITING_URL_ID', 'ra_REWRITING_URL_ID')->filterByView($view)->filterByViewLocale($viewLocale)->filterByViewId($viewId)->filterByRedirected(null)->orderById(Criteria::DESC); $otherParametersCount = count($viewOtherParameters); if ($otherParametersCount > 0) { $parameterConditions = array(); foreach ($viewOtherParameters as $parameter => $value) { $conditionName = 'other_parameter_condition_' . count($parameterConditions); $urlQuery->condition('parameter_condition', '`ra`.PARAMETER= ?', $parameter, \PDO::PARAM_STR)->condition('value_condition', '`ra`.VALUE = ?', $value, \PDO::PARAM_STR)->combine(array('parameter_condition', 'value_condition'), Criteria::LOGICAL_AND, $conditionName); $parameterConditions[] = $conditionName; } $urlQuery->where($parameterConditions, Criteria::LOGICAL_OR); $urlQuery->groupBy(RewritingUrlTableMap::ID); $urlQuery->condition('count_condition_1', 'COUNT(' . RewritingUrlTableMap::ID . ') = ?', $otherParametersCount, \PDO::PARAM_INT)->condition('count_condition_2', 'COUNT(' . RewritingUrlTableMap::ID . ') = (SELECT COUNT(*) FROM rewriting_argument WHERE rewriting_argument.REWRITING_URL_ID = ra_REWRITING_URL_ID)'); // ensure we don't miss any parameters (needed to match the rewritten url) $urlQuery->having(array('count_condition_1', 'count_condition_2'), Criteria::LOGICAL_AND); } else { $urlQuery->where('ISNULL(`ra`.REWRITING_URL_ID)'); } return $urlQuery->findOne(); }
/** * Get products * * @param $sitemap * @param $locale * @throws \Propel\Runtime\Exception\PropelException */ protected function setSitemapProducts(&$sitemap, $locale) { // Prepare query - get products URL $query = RewritingUrlQuery::create()->filterByView('product')->filterByRedirected(null)->filterByViewLocale($locale); // Join with visible products self::addJoinProduct($query); // Get products last update $query->withColumn(ProductTableMap::UPDATED_AT, 'PRODUCT_UPDATE_AT'); // Execute query $results = $query->find(); // For each result, hydrate XML file /** @var RewritingUrl $result */ foreach ($results as $result) { // Open new sitemap line & set product URL & update date $sitemap[] = ' <url> <loc>' . URL::getInstance()->absoluteUrl($result->getUrl()) . '</loc> <lastmod>' . date('c', strtotime($result->getVirtualColumn('PRODUCT_UPDATE_AT'))) . '</lastmod> </url>'; } }
public function testUpdateUrl() { $object = null; $event = $this->getUpdateSeoEvent($object); $event->setDispatcher($this->dispatcher); $currentUrl = $object->getRewrittenUrl($object->getLocale()); /* get a brand new URL */ $exist = true; while (true === $exist) { $newUrl = md5(rand(1, 999999)) . ".html"; try { new RewritingResolver($newUrl); } catch (UrlRewritingException $e) { if ($e->getCode() === UrlRewritingException::URL_NOT_FOUND) { /* It's all good if URL is not found */ $exist = false; } else { throw $e; } } } $event->setUrl($newUrl); $updatedObject = $this->processUpdateSeoAction($event); /* new URL is updated */ $this->assertEquals($newUrl, $updatedObject->getRewrittenUrl($object->getLocale())); /* old url must be redirected to the new one */ $newUrlEntry = RewritingUrlQuery::create()->findOneByUrl($newUrl); $oldUrlEntry = RewritingUrlQuery::create()->findOneByUrl($currentUrl); $this->assertEquals($oldUrlEntry->getRedirected(), $newUrlEntry->getId()); /* we can reassign old Url to another object */ $aRandomProduct = ProductQuery::create()->filterById($object->getId(), Criteria::NOT_EQUAL)->findOne(); $failReassign = true; try { $aRandomProduct->setRewrittenUrl($aRandomProduct->getLocale(), $currentUrl); $failReassign = false; } catch (\Exception $e) { } $this->assertFalse($failReassign); }
/** * Set the rewritten URL for the given locale * * @param string $locale a valid locale (e.g. en_US) * @param $url * @return $this * @throws UrlRewritingException * @throws \Thelia\Exception\UrlRewritingException */ public function setRewrittenUrl($locale, $url) { $currentUrl = $this->getRewrittenUrl($locale); if ($currentUrl == $url || null === $url) { /* no url update */ return $this; } try { $resolver = new RewritingResolver($url); /* we can reassign old url */ if (null === $resolver->redirectedToUrl) { /* else ... */ if ($resolver->view == $this->getRewrittenUrlViewName() && $resolver->viewId == $this->getId()) { /* it's an url related to the current object */ if ($resolver->locale != $locale) { /* it is an url related to this product for another locale */ throw new UrlRewritingException(Translator::getInstance()->trans('URL_ALREADY_EXISTS'), UrlRewritingException::URL_ALREADY_EXISTS); } if (count($resolver->otherParameters) > 0) { /* it is an url related to this product but with more arguments */ throw new UrlRewritingException(Translator::getInstance()->trans('URL_ALREADY_EXISTS'), UrlRewritingException::URL_ALREADY_EXISTS); } /* here it must be a deprecated url */ } else { /* already related to another object */ throw new UrlRewritingException(Translator::getInstance()->trans('URL_ALREADY_EXISTS'), UrlRewritingException::URL_ALREADY_EXISTS); } } } catch (UrlRewritingException $e) { /* It's all good if URL is not found */ if ($e->getCode() !== UrlRewritingException::URL_NOT_FOUND) { throw $e; } } /* set the new URL */ if (isset($resolver)) { /* erase the old one */ $rewritingUrl = RewritingUrlQuery::create()->findOneByUrl($url); $rewritingUrl->setView($this->getRewrittenUrlViewName())->setViewId($this->getId())->setViewLocale($locale)->setRedirected(null)->save(); /* erase additional arguments if any : only happens in case it erases a deprecated url */ RewritingArgumentQuery::create()->filterByRewritingUrl($rewritingUrl)->deleteAll(); } else { /* just create it */ $rewritingUrl = new RewritingUrl(); $rewritingUrl->setUrl($url)->setView($this->getRewrittenUrlViewName())->setViewId($this->getId())->setViewLocale($locale)->save(); } /* deprecate the old one if needed */ if (null !== ($oldRewritingUrl = RewritingUrlQuery::create()->findOneByUrl($currentUrl))) { $oldRewritingUrl->setRedirected($rewritingUrl->getId())->save(); } return $this; }
/** * Tries to match a request with a set of routes. * * If the matcher can not find information, it must throw one of the exceptions documented * below. * * @param Request $request The request to match * * @throws \Exception|\Thelia\Exception\UrlRewritingException * @throws \Symfony\Component\Routing\Exception\ResourceNotFoundException * @return array An array of parameters * */ public function matchRequest(Request $request) { if (ConfigQuery::isRewritingEnable()) { $urlTool = URL::getInstance(); $pathInfo = $request instanceof TheliaRequest ? $request->getRealPathInfo() : $request->getPathInfo(); try { $rewrittenUrlData = $urlTool->resolve($pathInfo); } catch (UrlRewritingException $e) { switch ($e->getCode()) { case UrlRewritingException::URL_NOT_FOUND: throw new ResourceNotFoundException(); break; default: throw $e; } } // If we have a "lang" parameter, whe have to check if the found URL has the proper locale // If it's not the case, find the rewritten URL with the requested locale, and redirect to it. if (null == !($requestedLocale = $request->get('lang'))) { if (null !== ($requestedLang = LangQuery::create()->findOneByLocale($requestedLocale))) { if ($requestedLang->getLocale() != $rewrittenUrlData->locale) { $localizedUrl = $urlTool->retrieve($rewrittenUrlData->view, $rewrittenUrlData->viewId, $requestedLang->getLocale())->toString(); $this->redirect($urlTool->absoluteUrl($localizedUrl), 301); } } } /* is the URL redirected ? */ if (null !== $rewrittenUrlData->redirectedToUrl) { $redirect = RewritingUrlQuery::create()->filterByView($rewrittenUrlData->view)->filterByViewId($rewrittenUrlData->viewId)->filterByViewLocale($rewrittenUrlData->locale)->filterByRedirected(null, Criteria::ISNULL)->findOne(); $this->redirect($urlTool->absoluteUrl($redirect->getUrl()), 301); } /* define GET arguments in request */ if (null !== $rewrittenUrlData->view) { $request->attributes->set('_view', $rewrittenUrlData->view); if (null !== $rewrittenUrlData->viewId) { $request->query->set($rewrittenUrlData->view . '_id', $rewrittenUrlData->viewId); } } if (null !== $rewrittenUrlData->locale) { $this->manageLocale($rewrittenUrlData, $request); } foreach ($rewrittenUrlData->otherParameters as $parameter => $value) { $request->query->set($parameter, $value); } return array('_controller' => 'Thelia\\Controller\\Front\\DefaultController::noAction', '_route' => 'rewrite', '_rewritten' => true); } throw new ResourceNotFoundException(); }
/** * covers RewritingRouter::matchRequest */ public function testMatchRequestWithDifferentLocaleAndDomain() { ConfigQuery::write('rewriting_enable', 1); ConfigQuery::write('one_domain_foreach_lang', 1); $defaultLang = LangQuery::create()->findOneByLocale('en_US'); $defaultLang->setUrl('http://test_en.com'); $frenchLang = LangQuery::create()->findOneByLocale('fr_FR'); $saveUrl = $frenchLang->getUrl(); $frenchLang->setUrl('http://test.com')->save(); $product = ProductQuery::create()->findOne(); $product->setLocale($defaultLang->getLocale()); $rewriting = RewritingUrlQuery::create()->filterByView('product')->filterByViewId($product->getId())->filterByViewLocale('fr_FR')->filterByRedirected(null)->findOne(); $request = Request::create('http://test_en.com/' . $rewriting->getUrl()); $session = new Session(new MockArraySessionStorage()); $session->setLang($defaultLang); $request->setSession($session); $url = new URL(); $requestContext = new RequestContext(); $requestContext->fromRequest($request); $url->setRequestContext($requestContext); try { $rewritingRouter = new RewritingRouter(); $parameters = $rewritingRouter->matchRequest($request); } catch (RedirectException $e) { $this->assertRegExp("/http:\\/\\/test\\.com\\/.*/", $e->getUrl()); return; } $this->fail('->matchRequest must throw a RedirectException'); }
/** * Performs an INSERT on the database, given a RewritingUrl or Criteria object. * * @param mixed $criteria Criteria or RewritingUrl object containing data that is used to create the INSERT statement. * @param ConnectionInterface $con the ConnectionInterface connection to use * @return mixed The new primary key. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(RewritingUrlTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { $criteria = $criteria->buildCriteria(); // build Criteria from RewritingUrl object } if ($criteria->containsKey(RewritingUrlTableMap::ID) && $criteria->keyContainsValue(RewritingUrlTableMap::ID)) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . RewritingUrlTableMap::ID . ')'); } // Set the correct dbName $query = RewritingUrlQuery::create()->mergeWith($criteria); try { // use transaction because $criteria could contain info // for more than one table (I guess, conceivably) $con->beginTransaction(); $pk = $query->doInsert($con); $con->commit(); } catch (PropelException $e) { $con->rollBack(); throw $e; } return $pk; }
/** * Get the associated ChildRewritingUrl object * * @param ConnectionInterface $con Optional Connection object. * @return ChildRewritingUrl The associated ChildRewritingUrl object. * @throws PropelException */ public function getRewritingUrl(ConnectionInterface $con = null) { if ($this->aRewritingUrl === null && $this->rewriting_url_id !== null) { $this->aRewritingUrl = ChildRewritingUrlQuery::create()->findPk($this->rewriting_url_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aRewritingUrl->addRewritingArguments($this); */ } return $this->aRewritingUrl; }
/** * @depends testCreateClone * @param ProductCloneEvent $event * @return ProductCloneEvent */ public function testUpdateClone(ProductCloneEvent $event) { $originalProductPrice = ProductPriceQuery::create()->findOneByProductSaleElementsId($event->getOriginalProduct()->getDefaultSaleElements()->getId()); // Call function to test $action = new Product(); $action->updateClone($event, $originalProductPrice); $cloneProduct = $event->getClonedProduct(); $this->assertInstanceOf('Thelia\\Model\\Product', $cloneProduct, 'Instance of clone product must be Thelia\\Model\\Product'); // Get I18ns $originalProductI18ns = ProductI18nQuery::create()->findById($event->getOriginalProduct()->getId()); $cloneProductI18ns = ProductI18nQuery::create()->filterById($cloneProduct->getId())->count(); $this->assertEquals(count($originalProductI18ns), $cloneProductI18ns, 'There must be the same quantity of I18ns'); // Check each I18n foreach ($originalProductI18ns as $originalProductI18n) { $cloneProductI18n = ProductI18nQuery::create()->findPk([$cloneProduct->getId(), $originalProductI18n->getLocale()]); $this->assertInstanceOf('Thelia\\Model\\ProductI18n', $cloneProductI18n, 'Instance of clone product I18n must be Thelia\\Model\\ProductI18n'); // I18n $this->assertEquals($originalProductI18n->getLocale(), $cloneProductI18n->getLocale(), 'Locale must be equal'); $this->assertEquals($originalProductI18n->getTitle(), $cloneProductI18n->getTitle(), 'Title must be equal'); $this->assertEquals($originalProductI18n->getChapo(), $cloneProductI18n->getChapo(), 'Chapo must be equal'); $this->assertEquals($originalProductI18n->getDescription(), $cloneProductI18n->getDescription(), 'Description must be equal'); $this->assertEquals($originalProductI18n->getPostscriptum(), $cloneProductI18n->getPostscriptum(), 'Postscriptum must be equal'); // SEO - Meta $this->assertEquals($originalProductI18n->getMetaTitle(), $cloneProductI18n->getMetaTitle(), 'MetaTitle must be equal'); $this->assertEquals($originalProductI18n->getMetaDescription(), $cloneProductI18n->getMetaDescription(), 'MetaDescription must be equal'); $this->assertEquals($originalProductI18n->getMetaKeywords(), $cloneProductI18n->getMetaKeywords(), 'MetaKeywords must be equal'); // SEO - Rewriting URL $originalUrl = RewritingUrlQuery::create()->filterByView('product')->filterByViewId($originalProductI18n->getId())->findOneByViewLocale($originalProductI18n->getLocale()); $cloneUrl = RewritingUrlQuery::create()->filterByView('product')->filterByViewId($cloneProduct->getId())->findOneByViewLocale($cloneProductI18n->getLocale()); $this->assertEquals('product', $cloneUrl->getView(), 'View must be equal to \'product\''); $this->assertEquals($cloneProduct->getId(), $cloneUrl->getViewId(), 'ViewID must be equal'); $this->assertEquals($originalProductI18n->getLocale(), $cloneUrl->getViewLocale(), 'ViewLocale must be equal to current I18n\'s locale'); $this->assertEquals($originalUrl->getRedirected(), $cloneUrl->getRedirected(), 'Redirect must be equal'); } // Check template $this->assertEquals($event->getOriginalProduct()->getTemplateId(), $cloneProduct->getTemplateId(), 'TemplateID must be equal'); $this->assertEquals($originalProductPrice->getCurrencyId(), $cloneProduct->getProductSaleElementss()->getFirst()->getProductPrices()->getFirst()->getCurrencyId(), 'Currency IDs must be equal'); return $event; }
/** * Returns a new ChildRewritingUrlQuery object. * * @param string $modelAlias The alias of a model in the query * @param Criteria $criteria Optional Criteria to build the query from * * @return ChildRewritingUrlQuery */ public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof \Thelia\Model\RewritingUrlQuery) { return $criteria; } $query = new \Thelia\Model\RewritingUrlQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
/** * @return mixed|\Thelia\Core\HttpFoundation\Response */ public function existAction() { if (null !== ($response = $this->checkAuth(array(AdminResources::MODULE), 'RewriteUrl', AccessManager::VIEW))) { return $response; } $search = $this->getRequest()->query->get('q'); $rewritingUrl = RewritingUrlQuery::create()->findOneByUrl($search); if ($rewritingUrl !== null) { if (in_array($rewritingUrl->getView(), $this->falseView)) { $redirectedUrls = RewritingUrlQuery::create()->filterByRedirected($rewritingUrl->getId()); /** @var RewritingUrl $redirectedUrl */ foreach ($redirectedUrls as $redirectedUrl) { $redirectedUrl->setRedirected(null)->save(); } $rewritingUrl->delete(); return $this->jsonResponse(json_encode(false)); } $route = $this->getRoute("admin." . $this->correspondence[$rewritingUrl->getView()] . ".update", [$rewritingUrl->getView() . '_id' => $rewritingUrl->getViewId()]); $url = URL::getInstance()->absoluteUrl($route, [$rewritingUrl->getView() . '_id' => $rewritingUrl->getViewId()]); $rewritingUrlArray = ["reassignUrl" => $url]; return $this->jsonResponse(json_encode($rewritingUrlArray)); } else { return $this->jsonResponse(json_encode(false)); } }
/** * @param string $url * @param string $view * @param int $id * @return RewritingUrl */ public function insertUrl($url, $view, $id) { //test if exist url principal $findUrlPrincipal = RewritingUrlQuery::create()->filterByView($view)->filterByViewId($id)->filterByRedirected(null)->findOne(); if ($findUrlPrincipal !== null) { $redirected = $findUrlPrincipal->getId(); } else { $redirected = null; } $local = LangQuery::create()->findOneByByDefault(1); $find = RewritingUrlQuery::create()->findOneByUrl($url); if ($find === null) { //insert RewritingUrl $insert = new RewritingUrl(); $insert->setUrl($url)->setView($view)->setViewId($id)->setRedirected($redirected)->setViewLocale($local->getLocale())->save(); } else { $insert = $find; } return $insert; }
/** * Returns the number of related RewritingUrl objects. * * @param Criteria $criteria * @param boolean $distinct * @param ConnectionInterface $con * @return int Count of related RewritingUrl objects. * @throws PropelException */ public function countRewritingUrlsRelatedById(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collRewritingUrlsRelatedByIdPartial && !$this->isNew(); if (null === $this->collRewritingUrlsRelatedById || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collRewritingUrlsRelatedById) { return 0; } if ($partial && !$criteria) { return count($this->getRewritingUrlsRelatedById()); } $query = ChildRewritingUrlQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query->filterByRewritingUrlRelatedByRedirected($this)->count($con); } return count($this->collRewritingUrlsRelatedById); }
protected function updateRewrittenUrl($t2_object, $locale, $id_lang_t1, $fond_t1, $params_t1) { try { $t1_obj = $this->t1db->query_obj("select * from reecriture where fond=? and param like? and lang=? and actif=1", array($fond_t1, "&{$params_t1}", $id_lang_t1)); } catch (\Exception $ex) { $t1_obj = false; } if ($t1_obj) { Tlog::getInstance()->info("Found rewritten URL {$t1_obj->url} for fond {$fond_t1}, with params {$params_t1}"); try { // Delete all previous instance for the T2 object and for the rewritten URL // Also empty url rewriting table $con = Propel::getConnection(RewritingUrlTableMap::DATABASE_NAME); $con->exec('SET FOREIGN_KEY_CHECKS=0'); RewritingUrlQuery::create()->filterByViewLocale($locale)->findByViewId($t2_object->getId())->delete(); RewritingUrlQuery::create()->filterByViewLocale($locale)->findByUrl($t1_obj->url)->delete(); $con->exec('SET FOREIGN_KEY_CHECKS=1'); $t2_object->setRewrittenUrl($locale, $t1_obj->url); Tlog::getInstance()->info("Imported rewritten URL for locale {$locale}, {$t1_obj->url}"); } catch (\Exception $ex) { Tlog::getInstance()->addError("Failed to create rewritten URL for locale {$locale}, fond {$fond_t1}, with params {$params_t1}: ", $ex->getMessage()); } } else { Tlog::getInstance()->addNotice("No rewritten URL was found for locale {$locale}, fond '{$fond_t1}', with params '{$params_t1}', lang {$id_lang_t1}"); } }