Пример #1
0
 /**
  * @param array $config
  * @return Extension
  */
 public function extensionFromConfig(array $config)
 {
     $extension = new Extension();
     $extension->setName(array_get($config, 'name'));
     $extension->setHandle(array_get($config, 'handle'));
     $asset = $this->assetList->getAsset('javascript', array_get($config, 'src'));
     if (!$asset) {
         $handle = array_get($config, 'handle');
         throw new \RuntimeException("Could not build extension \"{$handle}\", invalid extension asset.");
     } else {
         $extension->setExtensionAsset($asset);
     }
     $view = new View(array_get($config, 'view'));
     $extension->setView($view);
     $assets = (array) array_get($config, 'assets');
     foreach ($assets as $handle => $asset_config) {
         $asset_config = (array) $asset_config;
         foreach ($asset_config as $type) {
             if ($asset = $this->assetList->getAsset($type, $handle)) {
                 $extension->addAsset($asset);
             } else {
                 $handle = array_get($config, 'handle');
                 throw new \RuntimeException("Could not build extension \"{$handle}\", invalid asset.");
             }
         }
     }
     return $extension;
 }
Пример #2
0
 /**
  * @param string $assetType
  * @param string $assetHandle
  * @return Asset
  */
 public function getAsset($assetType, $assetHandle)
 {
     return parent::getAsset($assetType, $assetHandle);
 }