/** * Creates storage in module Disk. * This is core method. If you need to create user storage use Driver::addUserStorage, * if group storage use Driver::addGroupStorage, if common storage use Driver::addCommonStorage. * * @param array $data Array with fields. Necessary: NAME, MODULE_ID, ENTITY_ID, ENTITY_TYPE. * @param array $rights Array of rights. * @throws \Bitrix\Main\SystemException * @throws \Bitrix\Main\ArgumentException * @return null|Storage */ public function addStorage(array $data, array $rights = array()) { $this->errorCollection->clear(); $this->checkRequiredInputParams($data, array('NAME', 'MODULE_ID', 'ENTITY_TYPE', 'ENTITY_ID')); if (isset($data['USE_INTERNAL_RIGHTS']) && !$data['USE_INTERNAL_RIGHTS'] && !empty($rights)) { throw new ArgumentException('Attempt to set the rights, but not to use the internal rights.'); } /** @var Storage $storageModel */ $storageModel = Storage::add($data, $this->errorCollection); if (!$storageModel) { return null; } if ($storageModel->isUseInternalRights()) { Driver::getInstance()->getRightsManager()->setAsNewLeaf($storageModel->getRootObject(), $rights); } return $storageModel; }