tao-test/app/taoItems/models/classes/pack/ItemPacker.php

123 lines
3.5 KiB
PHP

<?php
/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2015 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
*
*
*/
namespace oat\taoItems\model\pack;
use \core_kernel_classes_Resource;
use \common_Exception;
use oat\oatbox\filesystem\Directory;
/**
* To allow packing of Item. The goal of the packaging is to represent the data needed
* to run an item (ie. an ItemPack).
*
* @package taoItems
*/
abstract class ItemPacker
{
/**
* Determines what type of assets should be packed as well as packer
* @example array('css'=>'base64')
* @var array
*/
protected $assetEncoders = [ 'js' => 'none',
'css' => 'none',
'font' => 'none',
'img' => 'none',
'audio' => 'none',
'video' => 'none'];
protected $nestedResourcesInclusion;
/** @var bool */
protected $skipValidation;
public function __construct($assetEncoders = [], $nestedResourcesInclusion = true, bool $skipValidation = false)
{
$this->assetEncoders = array_merge($this->assetEncoders, $assetEncoders);
$this->nestedResourcesInclusion = $nestedResourcesInclusion;
$this->skipValidation = $skipValidation;
}
/**
* Create a pack for an item.
*
* @param core_kernel_classes_Resource $item the item to pack
* @param string $lang
* @param Directory $directory
* @return \oat\taoItems\model\pack\ItemPack
*/
abstract public function packItem(core_kernel_classes_Resource $item, $lang, Directory $directory);
/**
* @deprecated by fly-authoring
*
* @param core_kernel_classes_Resource $item
* @param $lang
* @return string
* @throws common_Exception
*/
protected function getPath(core_kernel_classes_Resource $item, $lang = "")
{
throw new \BadMethodCallException(__CLASS__ . ' - ' . __METHOD__ . ' disable by fly-authoring');
}
/**
* @return array
*/
protected function getAssetEncoders()
{
return $this->assetEncoders;
}
/**
* @param array $assetEncoders
*/
public function setAssetEncoders(array $assetEncoders)
{
$this->assetEncoders = $assetEncoders;
}
/**
* @return boolean
*/
public function isNestedResourcesInclusion()
{
return $this->nestedResourcesInclusion;
}
/**
* @param boolean $nestedResourcesInclusion
*/
public function setNestedResourcesInclusion($nestedResourcesInclusion)
{
$this->nestedResourcesInclusion = $nestedResourcesInclusion;
}
public function setSkipValidation(bool $skipValidation): void
{
$this->skipValidation = $skipValidation;
}
}