示例#1
0
 public function testRender()
 {
     $asserts = new Assets();
     $asserts->fromArray(['foo' => 'foo.js', 'bar' => ['bar.js'], 'baz' => ['extends' => 'bar'], 'qux' => ['extends' => ['foo', 'baz'], 'sources' => ['qux.js', 'qux.css']]]);
     $asserts->uses('qux');
     $expected = '<link href="qux.css" rel="stylesheet" />' . PHP_EOL . '<script src="foo.js"></script>' . PHP_EOL . '<script src="bar.js"></script>' . PHP_EOL . '<script src="qux.js"></script>';
     $result = $asserts->render();
     $this->assertSame($expected, $result);
 }
示例#2
0
文件: Assets.php 项目: lytc/sloths
 public function getJs()
 {
     $sources = [];
     foreach ($this->parents as $parentGroupName) {
         $sources = array_replace($sources, $this->assets->getGroup($parentGroupName)->getJs());
     }
     $sources = array_replace($sources, $this->js);
     foreach ($sources as &$source) {
         $source = $this->assets->prepareSource($source);
     }
     return $sources;
 }