/** * @param $object * @param $attribute * * @return null */ protected function validateAttribute($object, $attribute) { $urlFormat = $object->{$attribute}; if ($urlFormat) { // Remove any leading or trailing spaces/slashes $urlFormat = trim($urlFormat, '/ '); $object->{$attribute} = $urlFormat; if ($this->requireSlug) { if (!ElementHelper::doesUrlFormatHaveSlugTag($urlFormat)) { $this->addError($object, $attribute, Craft::t('{attribute} must contain “{slug}”')); } } } }