added isAttributeActive to Model

consistent api for safe and required
This commit is contained in:
Carsten Brandt
2013-10-13 19:50:14 +02:00
parent a1e6c16e39
commit 1600889f4e

View File

@@ -422,12 +422,24 @@ class Model extends Component implements IteratorAggregate, ArrayAccess
* Returns a value indicating whether the attribute is safe for massive assignments. * Returns a value indicating whether the attribute is safe for massive assignments.
* @param string $attribute attribute name * @param string $attribute attribute name
* @return boolean whether the attribute is safe for massive assignments * @return boolean whether the attribute is safe for massive assignments
* @see safeAttributes()
*/ */
public function isAttributeSafe($attribute) public function isAttributeSafe($attribute)
{ {
return in_array($attribute, $this->safeAttributes(), true); return in_array($attribute, $this->safeAttributes(), true);
} }
/**
* Returns a value indicating whether the attribute is active in the current scenario.
* @param string $attribute attribute name
* @return boolean whether the attribute is active in the current scenario
* @see activeAttributes()
*/
public function isAttributeActive($attribute)
{
return in_array($attribute, $this->activeAttributes(), true);
}
/** /**
* Returns the text label for the specified attribute. * Returns the text label for the specified attribute.
* @param string $attribute the attribute name * @param string $attribute the attribute name