createFromSettings() public static method

public static createFromSettings ( array $settings ) : Asset
$settings array
return Asset
 /**
  * @param array $asset
  * @return void
  */
 protected function loadByVhs(array $asset)
 {
     if (GeneralUtility::getApplicationContext()->isDevelopment()) {
         $developmentFile = $this->getDevelopmentFile($asset);
         if ($developmentFile) {
             $asset['path'] = str_replace('.min.', '.', $asset['path']);
         }
     }
     Asset::createFromSettings($asset);
 }
Beispiel #2
0
 /**
  * @param array $parameters
  * @param object $caller
  * @param boolean $cached If TRUE, treats this inclusion as happening in a cached context
  * @return void
  */
 public function buildAll(array $parameters, $caller, $cached = TRUE)
 {
     if (FALSE === $this->objectManager instanceof \TYPO3\CMS\Extbase\Object\ObjectManager) {
         $this->objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
         $this->configurationManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManagerInterface');
     }
     $settings = $this->getSettings();
     $cached = (bool) $cached;
     if (FALSE === self::$typoScriptAssetsBuilt && TRUE === isset($settings['asset']) && TRUE === is_array($settings['asset'])) {
         foreach ($settings['asset'] as $name => $typoScriptAsset) {
             if (FALSE === isset($GLOBALS['VhsAssets'][$name]) && TRUE === is_array($typoScriptAsset)) {
                 if (FALSE === isset($typoScriptAsset['name'])) {
                     $typoScriptAsset['name'] = $name;
                 }
                 Asset::createFromSettings($typoScriptAsset);
             }
         }
         self::$typoScriptAssetsBuilt = TRUE;
     }
     if (FALSE === isset($GLOBALS['VhsAssets']) || FALSE === is_array($GLOBALS['VhsAssets'])) {
         return;
     }
     $assets = $GLOBALS['VhsAssets'];
     $assets = $this->sortAssetsByDependency($assets);
     $assets = $this->manipulateAssetsByTypoScriptSettings($assets);
     $buildDebugRequested = isset($settings['asset']['debugBuild']) && $settings['asset']['debugBuild'] > 0;
     $assetDebugRequested = isset($settings['asset']['debug']) && $settings['asset']['debug'] > 0;
     $useDebugUtility = isset($settings['asset']['useDebugUtility']) && $settings['asset']['useDebugUtility'] > 0 || FALSE === isset($settings['asset']['useDebugUtility']);
     if (TRUE === ($buildDebugRequested || $assetDebugRequested)) {
         if (TRUE === $useDebugUtility) {
             DebuggerUtility::var_dump($assets);
         } else {
             echo var_export($assets, TRUE);
         }
     }
     $this->placeAssetsInHeaderAndFooter($assets, $cached);
 }
Beispiel #3
0
 /**
  * @test
  */
 public function createAssetInstanceFromStaticSettingsFactoryRemapsDeprecatedProperties()
 {
     $file = $this->getAbsoluteAssetFixturePath();
     $settings = array('file' => $file, 'arguments' => array('foo' => 'bar'), 'allowMoveToFooter' => FALSE);
     $asset = Asset::createFromSettings($settings);
     $this->assertAttributeEquals($settings['arguments'], 'variables', $asset);
     $this->assertAttributeEquals($settings['allowMoveToFooter'], 'movable', $asset);
 }
Beispiel #4
0
 /**
  * @param array $parameters
  * @param object $caller
  * @param boolean $cached If TRUE, treats this inclusion as happening in a cached context
  * @return void
  */
 public function buildAll(array $parameters, $caller, $cached = true)
 {
     if (false === $this->objectManager instanceof ObjectManager) {
         $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class);
         $this->configurationManager = $this->objectManager->get(ConfigurationManagerInterface::class);
     }
     $settings = $this->getSettings();
     $cached = (bool) $cached;
     $buildTypoScriptAssets = !static::$typoScriptAssetsBuilt && ($cached || $GLOBALS['TSFE']->no_cache);
     if ($buildTypoScriptAssets && isset($settings['asset']) && is_array($settings['asset'])) {
         foreach ($settings['asset'] as $name => $typoScriptAsset) {
             if (!isset($GLOBALS['VhsAssets'][$name]) && is_array($typoScriptAsset)) {
                 if (!isset($typoScriptAsset['name'])) {
                     $typoScriptAsset['name'] = $name;
                 }
                 Asset::createFromSettings($typoScriptAsset);
             }
         }
         static::$typoScriptAssetsBuilt = true;
     }
     if (!isset($GLOBALS['VhsAssets']) || !is_array($GLOBALS['VhsAssets'])) {
         return;
     }
     $assets = $GLOBALS['VhsAssets'];
     $assets = $this->sortAssetsByDependency($assets);
     $assets = $this->manipulateAssetsByTypoScriptSettings($assets);
     $buildDebugRequested = isset($settings['asset']['debugBuild']) && $settings['asset']['debugBuild'] > 0;
     $assetDebugRequested = isset($settings['asset']['debug']) && $settings['asset']['debug'] > 0;
     $useDebugUtility = isset($settings['asset']['useDebugUtility']) && $settings['asset']['useDebugUtility'] > 0 || false === isset($settings['asset']['useDebugUtility']);
     if (true === ($buildDebugRequested || $assetDebugRequested)) {
         if (true === $useDebugUtility) {
             DebuggerUtility::var_dump($assets);
         } else {
             echo var_export($assets, true);
         }
     }
     $this->placeAssetsInHeaderAndFooter($assets, $cached);
 }
 /**
  * @test
  */
 public function canCreateAssetInstanceFromStaticSettingsFactory()
 {
     $file = $this->getAbsoluteAssetFixturePath();
     $settings = array('file' => $file);
     $asset = Asset::createFromSettings($settings);
     $this->assertInstanceOf('FluidTYPO3\\Vhs\\Asset', $asset);
 }