function apply(VF_Vehicle $descendant) { $titles = $descendant->toTitleArray(); $levelsToReplace = $this->getSchema()->getPrevLevelsIncluding($this->grain); foreach ($levelsToReplace as $levelToReplace) { $replacementTitle = $this->vehicle()->getLevel($levelToReplace)->getTitle(); $titles[$levelToReplace] = $replacementTitle; } foreach ($this->newTitles as $replacementTitle) { $titles[$this->grain] = $replacementTitle; $new_vehicle = VF_Vehicle::create($this->getSchema(), $titles); $new_vehicle->save(); $this->mergeFitments($descendant, $new_vehicle); } }
function assertMMYTitlesEquals($make, $model, $year, VF_Vehicle $vehicle) { $expected = array('make' => $make, 'model' => $model, 'year' => $year); $this->assertEquals($expected, $vehicle->toTitleArray()); }
function vehicleSlug(VF_Vehicle $vehicle) { $config = $this->getConfig(); $rewriteLevels = $config->seo->rewriteLevels; if ($rewriteLevels) { $rewriteLevels = explode(',', $rewriteLevels); $slug = implode('~', $vehicle->toTitleArray($rewriteLevels)); } else { $slug = implode('~', $vehicle->toTitleArray()); } $slug = str_replace(' ', '-', $slug); $slug = str_replace('%7E', '~', urlencode($slug)); // url encode everything but tildes return $slug; }