1 <?php
2 /* --------------------------------------------------------------
3 AssetCollection.inc.php 2015-03-13 gm
4 Gambio GmbH
5 http://www.gambio.de
6 Copyright (c) 2015 Gambio GmbH
7 Released under the GNU General Public License (Version 2)
8 [http://www.gnu.org/licenses/gpl-2.0.html]
9 --------------------------------------------------------------
10 */
11
12 MainFactory::load_class('AbstractCollection');
13 MainFactory::load_class('AssetCollectionInterface');
14
15 /**
16 * Class AssetCollection
17 *
18 * Handles Asset objects (JavaScript and CSS). Use the getHtml() method
19 * to get the HTML output for the collection. The elements will be outputted
20 * in the same order they were added in the collection.
21 *
22 * @category System
23 * @package Http
24 * @subpackage Collections
25 */
26 class AssetCollection extends AbstractCollection implements AssetCollectionInterface
27 {
28 /**
29 * Adds a new asset to the collection.
30 *
31 * @param AssetInterface $asset
32 */
33 public function add(AssetInterface $asset)
34 {
35 $this->_add($asset);
36 }
37
38
39 /**
40 * Prints the HTML markup for the assets.
41 *
42 * @return string Returns the HTML markup of the assets.
43 */
44 public function getHtml()
45 {
46 $html = '';
47 foreach($this->collectionContentArray as $asset)
48 {
49 $html .= (string)$asset . PHP_EOL;
50 }
51
52 return $html;
53 }
54
55
56 /**
57 * Returns the type of the collection items.
58 *
59 * @return string
60 */
61 protected function _getValidType()
62 {
63 return 'AssetInterface';
64 }
65 }