/** * Test case setup */ public function setUp() { parent::setUp(); $this->wildcard = new eZURLWildcard(array('source_url' => 'MyRootURL', 'destination_url' => '/', 'type' => eZURLWildcard::TYPE_DIRECT)); $this->wildcard->store(); eZURLWildcard::expireCache(); }
if (!is_array($rows)) { break; } $count = count($rows); foreach ($rows as $key => $row) { $wildcardType = (int) $row['is_wildcard']; // 1 is forward, 2 is direct (alias) for now they are both treated as forwarding/redirect $sourceWildcard = $row['source_url']; $sourceWildcard = eZURLAliasML::sanitizeURL($sourceWildcard); $destinationWildcard = $row['destination_url']; $destinationWildcard = eZURLAliasML::sanitizeURL($destinationWildcard); if ($row['is_wildcard'] && $row['is_internal'] != 1) { // If the wildcard is made by a user we import using the new wildcard system. $row['type'] = (int) $row['is_wildcard']; $wildcard = new eZURLWildcard($row); $wildcard->store(); list($column, $counter) = displayProgress('.', $urlImportStartTime, $counter, $urlCount, $column); continue; } while (true) { // Validate the wildcards if (!preg_match("#^(.*)\\*\$#", $sourceWildcard, $matches)) { logError("Invalid source wildcard '{$sourceWildcard}', item is skipped, URL entry ID is " . $row['id']); list($column, $counter) = displayProgress('E', $urlImportStartTime, $counter, $urlCount, $column); continue 2; } $fromPath = $matches[1]; $fromPath = eZURLAliasML::sanitizeURL($fromPath); if (!preg_match("#^(.*)\\{1\\}\$#", $destinationWildcard, $matches)) { logError("Invalid destination wildcard '{$destinationWildcard}', item is skipped, URL entry ID is " . $row['id']); list($column, $counter) = displayProgress('E', $urlImportStartTime, $counter, $urlCount, $column);
/** * Helper method that creates a wildcard * * @param string $sourceURL * @param string $destinationURL * @param int $type * @return eZURLWildcard the created wildcard persistent object */ public static function createWildcard($sourceURL, $destinationURL, $type) { $row = array('source_url' => $sourceURL, 'destination_url' => $destinationURL, 'type' => $type); $wildcard = new eZURLWildcard($row); $wildcard->store(); return $wildcard; }