public function __construct($resourceId, $definitionItem)
{
$this->resourceId = $resourceId;
$this->name = $definitionItem[0];
$this->description = $definitionItem[1];
$this->group = $definitionItem[2];
$this->permissions = array();
if (isset($definitionItem[3])) {
// ACL Resource Permissions
if (!is_array($definitionItem[3])) {
throw new Exception\ResourceObjectException(sprintf("Third value of the definition array must be array of the unique permissions and should look like " . "array(permission_id => description), %s given", gettype($definitionItem[3])));
}
foreach ($definitionItem[3] as $permissionid => $description) {
if (!is_string($description)) {
throw new Exception\ResourceObjectException(sprintf("String is expected for description value, %s given. " . "Array of unique permissions should look like array(permission_id => description)", gettype($description)));
}
$this->permissions[strtolower($permissionid)] = $description;
}
}
if (isset($definitionItem[4])) {
//ACL Resource Mode
if (!$definitionItem[4] instanceof ModeInterface) {
throw new Exception\ResourceObjectException(sprintf("Forth value of the definition array must be instance of Scalr\\Acl\\Resource\\ModeInterface, %s given.", is_object($definitionItem[4]) ? get_class($definitionItem[4]) : gettype($definitionItem[4])));
}
$this->mode = $definitionItem[4];
if ($this->resourceId != $this->mode->getResourceId()) {
throw new Exception\ResourceObjectException(sprintf("There is a mismatch in the Resource identifiers of the %s ACL Resource and its Mode", $this->name));
}
}
}