Ejemplo n.º 1
0
 public function testGetType()
 {
     $asset = new Asset([Asset::ATTR_TYPE => 'image']);
     $this->assertEquals('image', $asset->getType());
     $asset = new Asset([Asset::ATTR_TYPE => 'video']);
     $this->assertEquals('video', $asset->getType());
     $asset = new Asset();
     $this->assertEquals('', $asset->getType());
 }
Ejemplo n.º 2
0
 /**
  * Return the controller to be used to display an asset.
  *
  * @param Asset $asset
  *
  * @return string
  */
 public static function controller(AssetModel $asset)
 {
     $namespace = 'BoomCMS\\Http\\Controllers\\ViewAsset\\';
     if (!$asset->getExtension()) {
         return;
     }
     $byExtension = $namespace . ucfirst($asset->getExtension());
     if (class_exists($byExtension)) {
         return $byExtension;
     }
     $byType = $namespace . ucfirst($asset->getType());
     if (class_exists($byType)) {
         return $byType;
     }
     return $namespace . 'BaseController';
 }