/** * Internal function to run variable tags * * @param String $type * @param Array $assets * @param Array $settings * @return String */ protected function _run($type, $assets, $settings = array()) { MinimeePlugin::log(Craft::t('MinimeeVariable::' . $type . '() is being run now.')); $minified = minimee()->service->run($type, $assets, $settings); if (!$minified) { $html = minimee()->service->makeTagsByType($type, $assets); return minimee()->service->makeTwigMarkupFromHtml($html); } $html = minimee()->service->makeTagsByType($type, $minified); return minimee()->service->makeTwigMarkupFromHtml($html); }
/** * Define our filter * * @param String $html * @param Array $settings * @return String */ public function minimeeFilter($html, $settings = array()) { // we need a type to continue $type = $this->detectType($html); if (!$type) { MinimeePlugin::log('Could not determine the type of asset to process.', LogLevel::Warning); return minimee()->service->makeTwigMarkupFromHtml($html); } // we need to find some assets in the HTML $assets = $this->pregMatchAssetsByType($type, $html); if (!$assets) { MinimeePlugin::log('No assets of type ' . $type . ' could be found.', LogLevel::Warning); return minimee()->service->makeTwigMarkupFromHtml($html); } // hand off the rest to our service $minified = minimee()->service->run($type, $assets, $settings); // false means we failed, so return original markup if (!$minified) { return minimee()->service->makeTwigMarkupFromHtml($html); } $minifiedAsTags = minimee()->service->makeTagsByType($type, $minified); // return minified tag(s) as Twig Markup return minimee()->service->makeTwigMarkupFromHtml($minifiedAsTags); }
/** * Configure our service based off the settings in plugin, * allowing plugin settings to be overridden at runtime. * * @param Array $settingsOverrides * @return void */ protected function setRuntimeSettings($settingsOverrides) { $settingsOverrides = !is_array($settingsOverrides) ? array($settingsOverrides) : $settingsOverrides; $settingsOverrides = $this->supportLegacyNamesAtRuntime($settingsOverrides); $runtimeSettings = array_merge($this->getPluginSettings(), $settingsOverrides); $this->settings = minimee()->makeSettingsModel($runtimeSettings); return $this; }
/** * Either create a fresh instance of Guzzle\Http\Client, or pass the instance we were given during instantiation. */ protected function _getInstanceOfClient() { return minimee()->makeClient(); }