/**
  * Given post data, which would be coming most likely from the ExplicitReadWriteModelPermissionsElement,
  * transform the post data into a ExplicitReadWriteModelPermissions object.  If the post data contains a 'type'
  * value that is not supported, an exception is thrown.
  * @param array $postData
  * @see ExplicitReadWriteModelPermissionsElement
  */
 public static function makeByPostData($postData)
 {
     assert('is_array($postData)');
     $explicitReadWriteModelPermissions = new ExplicitReadWriteModelPermissions();
     if ($postData['type'] == null) {
         return $explicitReadWriteModelPermissions;
     } elseif ($postData['type'] == ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_EVERYONE_GROUP) {
         $explicitReadWriteModelPermissions->addReadWritePermitable(Group::getByName(Group::EVERYONE_GROUP_NAME));
         return $explicitReadWriteModelPermissions;
     } elseif ($postData['type'] == ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_NONEVERYONE_GROUP) {
         assert('isset($postData["nonEveryoneGroup"])');
         $explicitReadWriteModelPermissions->addReadWritePermitable(Group::getById((int) $postData["nonEveryoneGroup"]));
         return $explicitReadWriteModelPermissions;
     } else {
         throw notSupportedException();
     }
 }
示例#2
0
 public static function resolveInputNamePrefixIntoString($inputNamePrefix)
 {
     assert('is_string($inputNamePrefix) || is_array($inputNamePrefix)');
     if (is_array($inputNamePrefix)) {
         if (count($inputNamePrefix) > 1) {
             $inputPrefixContent = null;
             $firstPrefixPlaced = false;
             foreach ($inputNamePrefix as $value) {
                 if (!$firstPrefixPlaced) {
                     $inputPrefixContent .= $value;
                     $firstPrefixPlaced = true;
                 } else {
                     $inputPrefixContent .= '[' . $value . ']';
                 }
             }
             return $inputPrefixContent;
         }
     } elseif (!is_string($inputNamePrefix)) {
         throw notSupportedException();
     }
     return $inputNamePrefix;
 }
 /**
  * Add a permitable object that needs to be removed from the securable item.
  * @param object $permitable
  */
 public function addReadWritePermitableToRemove($permitable)
 {
     assert('$permitable instanceof Permitable');
     if (!isset($this->readWritePermitablesToRemove[$permitable->id])) {
         $this->readWritePermitablesToRemove[$permitable->id] = $permitable;
     } else {
         throw notSupportedException();
     }
 }