thelia-modules /
RewriteUrl
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /*************************************************************************************/ |
||
| 3 | /* This file is part of the RewriteUrl module for Thelia. */ |
||
| 4 | /* */ |
||
| 5 | /* Copyright (c) OpenStudio */ |
||
| 6 | /* email : [email protected] */ |
||
| 7 | /* web : http://www.thelia.net */ |
||
| 8 | /* */ |
||
| 9 | /* For the full copyright and license information, please view the LICENSE.txt */ |
||
| 10 | /* file that was distributed with this source code. */ |
||
| 11 | /*************************************************************************************/ |
||
| 12 | |||
| 13 | namespace RewriteUrl; |
||
| 14 | |||
| 15 | use Propel\Runtime\Connection\ConnectionInterface; |
||
| 16 | use Thelia\Model\ConfigQuery; |
||
| 17 | use Thelia\Model\Map\RewritingUrlTableMap; |
||
| 18 | use Thelia\Model\RewritingUrl; |
||
| 19 | use Thelia\Model\RewritingUrlQuery; |
||
| 20 | use Thelia\Module\BaseModule; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Class RewriteUrl |
||
| 24 | * @package RewriteUrl |
||
| 25 | * @author Vincent Lopes <[email protected]> |
||
| 26 | * @author Gilles Bourgeat <[email protected]> |
||
| 27 | */ |
||
| 28 | class RewriteUrl extends BaseModule |
||
| 29 | { |
||
| 30 | /** @var string */ |
||
| 31 | const MODULE_DOMAIN = "rewriteurl"; |
||
| 32 | |||
| 33 | /** @var string */ |
||
| 34 | const MODULE_NAME = "rewriteurl"; |
||
| 35 | |||
| 36 | /** @static null|array */ |
||
| 37 | static $unknownSources; |
||
|
0 ignored issues
–
show
|
|||
| 38 | |||
| 39 | /** |
||
| 40 | * @param string $currentVersion |
||
| 41 | * @param string $newVersion |
||
| 42 | * @param ConnectionInterface $con |
||
| 43 | * @throws \Exception |
||
| 44 | * @throws \Propel\Runtime\Exception\PropelException |
||
| 45 | * @since 1.2.3 |
||
| 46 | */ |
||
| 47 | public function update($currentVersion, $newVersion, ConnectionInterface $con = null) |
||
| 48 | { |
||
| 49 | /* |
||
| 50 | * Fix for urls that redirect on itself |
||
| 51 | */ |
||
| 52 | $urls = RewritingUrlQuery::create() |
||
| 53 | ->where(RewritingUrlTableMap::ID . " = " . RewritingUrlTableMap::REDIRECTED) |
||
| 54 | ->find(); |
||
| 55 | |||
| 56 | /** @var RewritingUrl $url */ |
||
| 57 | foreach ($urls as $url) { |
||
| 58 | $parent = RewritingUrlQuery::create() |
||
| 59 | ->filterByView($url->getView()) |
||
| 60 | ->filterByViewId($url->getViewId()) |
||
| 61 | ->filterByViewLocale($url->getViewLocale()) |
||
| 62 | ->filterByRedirected(null) |
||
| 63 | ->findOne(); |
||
| 64 | |||
| 65 | $url->setRedirected(($parent === null) ? null : $parent->getId())->save(); |
||
| 66 | } |
||
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @return array|null |
||
| 71 | */ |
||
| 72 | public static function getUnknownSources() |
||
| 73 | { |
||
| 74 | if (static::$unknownSources === null) { |
||
|
0 ignored issues
–
show
Since
$unknownSources is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $unknownSources to at least protected.
Let’s assume you have a class which uses late-static binding: class YourClass
{
private static $someVariable;
public static function getSomeVariable()
{
return static::$someVariable;
}
}
The code above will run fine in your PHP runtime. However, if you now create a
sub-class and call the class YourSubClass extends YourClass { }
YourSubClass::getSomeVariable(); // Will cause an access error.
In the case above, it makes sense to update class SomeClass
{
private static $someVariable;
public static function getSomeVariable()
{
return self::$someVariable; // self works fine with private.
}
}
Loading history...
|
|||
| 75 | static::$unknownSources = []; |
||
|
0 ignored issues
–
show
Since
$unknownSources is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $unknownSources to at least protected.
Let’s assume you have a class which uses late-static binding: class YourClass
{
private static $someVariable;
public static function getSomeVariable()
{
return static::$someVariable;
}
}
The code above will run fine in your PHP runtime. However, if you now create a
sub-class and call the class YourSubClass extends YourClass { }
YourSubClass::getSomeVariable(); // Will cause an access error.
In the case above, it makes sense to update class SomeClass
{
private static $someVariable;
public static function getSomeVariable()
{
return self::$someVariable; // self works fine with private.
}
}
Loading history...
|
|||
| 76 | if (null !== $config = ConfigQuery::read('obsolete_rewriten_url_view', null)) { |
||
| 77 | static::$unknownSources[] = $config; |
||
|
0 ignored issues
–
show
Since
$unknownSources is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $unknownSources to at least protected.
Let’s assume you have a class which uses late-static binding: class YourClass
{
private static $someVariable;
public static function getSomeVariable()
{
return static::$someVariable;
}
}
The code above will run fine in your PHP runtime. However, if you now create a
sub-class and call the class YourSubClass extends YourClass { }
YourSubClass::getSomeVariable(); // Will cause an access error.
In the case above, it makes sense to update class SomeClass
{
private static $someVariable;
public static function getSomeVariable()
{
return self::$someVariable; // self works fine with private.
}
}
Loading history...
|
|||
| 78 | } |
||
| 79 | } |
||
| 80 | return static::$unknownSources; |
||
|
0 ignored issues
–
show
Since
$unknownSources is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $unknownSources to at least protected.
Let’s assume you have a class which uses late-static binding: class YourClass
{
private static $someVariable;
public static function getSomeVariable()
{
return static::$someVariable;
}
}
The code above will run fine in your PHP runtime. However, if you now create a
sub-class and call the class YourSubClass extends YourClass { }
YourSubClass::getSomeVariable(); // Will cause an access error.
In the case above, it makes sense to update class SomeClass
{
private static $someVariable;
public static function getSomeVariable()
{
return self::$someVariable; // self works fine with private.
}
}
Loading history...
|
|||
| 81 | } |
||
| 82 | } |
||
| 83 |
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using
the property is implicitly global.
To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.