/** * Returns the translated definition for the word hatred * * {Injects a static method dependency for Craft::t} * * @param string $translator The name of the static class that defines t() * * @return string */ public function getTranslatedDefinition(BaseModel $model) { if ($model->validate()) { // Static method dependencies are just not elegant to work with // We can use $model->property but using $model->getAttribute('property') make this method more testable return call_user_func_array($this->translator . '::t', array($model->getAttribute('definition'))); } return false; }
/** * Gets an attribute's value. * * @param string $name * @param bool $flattenValue * @return mixed */ public function getAttribute($name, $flattenValue = false) { // Flatten packages into a comma-delimited string, rather than JSON if ($name == 'packages' && $flattenValue) { return implode(',', parent::getAttribute('packages')); } else { return parent::getAttribute($name, $flattenValue); } }
/** * Modify default behavior of getAttribute to include Meta value into this model attributes. * * @param string $key * @return mixed */ public function getAttribute($key) { if (in_array($key, $this->metaKeys)) { return $this->getMetaKeyValue($key); } return parent::getAttribute($key); }
/** * @inheritDoc BaseModel::getAttribute() * * @param string $name * @param bool $flattenValue * * @return mixed */ public function getAttribute($name, $flattenValue = false) { return parent::getAttribute($name, $flattenValue); }
/** * @inheritDoc BaseModel::getAttribute() * * @param string $name * @param bool $flattenValue * * @return mixed */ public function getAttribute($name, $flattenValue = false) { $value = parent::getAttribute($name, $flattenValue); if ($name == 'path' && !empty($value)) { $value = rtrim($value, '/') . '/'; } return $value; }
/** * Inject our model attribute accessors. * * @param String $string * @return String */ public function getAttribute($name) { switch ($name) { case 'baseUrl': return $this->getBaseUrl(); break; case 'cachePath': return $this->getCachePath(); break; case 'cacheUrl': return $this->getCacheUrl(); break; case 'cssReturnTemplate': return $this->getCssReturnTemplate(); break; case 'filesystemPath': return $this->getFilesystemPath(); break; case 'jsReturnTemplate': return $this->getJsReturnTemplate(); break; case 'returnType': return $this->getReturnType(); break; } return parent::getAttribute($name); }
/** * Inject our model attribute accessors. * * @param String $name * @param Bool $flattenValue * @return String|Bool */ public function getAttribute($name, $flattenValue = false) { switch ($name) { case 'baseUrl': return $this->getBaseUrl(); case 'cachePath': return $this->getCachePath(); case 'cacheUrl': return $this->getCacheUrl(); case 'cssReturnTemplate': return $this->getCssReturnTemplate(); case 'cssPrependUrl': return $this->getCssPrependUrl(); case 'filesystemPath': return $this->getFilesystemPath(); case 'jsReturnTemplate': return $this->getJsReturnTemplate(); case 'returnType': return $this->getReturnType(); default: return parent::getAttribute($name, $flattenValue); } }