src/Phassets/Phassets.php
public function work($file, $customFilters = null, $customDeployer = null)
    {
        // Create the Asset instance
        foreach ($this->assetsSource as $source) {
            if (is_file($source . DIRECTORY_SEPARATOR . $file)) {
                $asset = $this->objectsFactory->buildAsset($source . DIRECTORY_SEPARATOR . $file);
            }
        }

        if (!isset($asset)) {
            $asset = $this->objectsFactory->buildAsset($file);
        }

        // Assemble the $filters array of fully qualified filters class names
        if (is_array($customFilters)) {
            $filters = $customFilters;
        } else {
            $ext = $asset->getExtension();
            $filters = isset($this->filters[$ext]) ? $this->filters[$ext] : array();
        }

        // Decide which deployer will be used.
        if (is_string($customDeployer)) {
            $deployer = $customDeployer;
        } else {
            $deployer = $this->loadedDeployer;
        }

        // Is previously cached?
        $cacheKey = $this->computeCacheKey($asset->getFullPath(), $filters, $deployer);
        $cacheValue = $this->loadedCacheAdapter->get($cacheKey);

        if ($cacheValue !== false) {
            $asset->setOutputUrl($cacheValue);

            return $asset;
        }

        // If there is any different extension, then set it first
        $this->applyFilterOutputExtension($filters, $asset);

        // Is previously deployed?
        if (isset($this->deployersInstances[$deployer]) && $this->deployersInstances[$deployer]->isPreviouslyDeployed($asset)) {
            // Cache the result
            $cacheValue = $asset->getOutputUrl();
            $this->loadedCacheAdapter->save($cacheKey, $cacheValue, $this->cacheTtl);

            return $asset;
        }

        // Pass the asset through all filters.
        $this->filterAsset($filters, $asset);

        // All set! Let's deploy now.
        $this->deployAsset($deployer, $asset);

        // Cache the result
        $cacheValue = $asset->getOutputUrl();
        $this->loadedCacheAdapter->save($cacheKey, $cacheValue, $this->cacheTtl);

        return $asset;
    }
public function work($file, $customFilters = null, $customDeployer = null)
    {
        // Create the Asset instance
        foreach ($this->assetsSource as $source) {
            if (is_file($source . DIRECTORY_SEPARATOR . $file)) {
                $asset = $this->objectsFactory->buildAsset($source . DIRECTORY_SEPARATOR . $file);
            }
        }

        if (!isset($asset)) {
            $asset = $this->objectsFactory->buildAsset($file);
        }

        // Assemble the $filters array of fully qualified filters class names
        if (is_array($customFilters)) {
            $filters = $customFilters;
        } else {
            $ext = $asset->getExtension();
            $filters = isset($this->filters[$ext]) ? $this->filters[$ext] : array();
        }

        // Decide which deployer will be used.
        if (is_string($customDeployer)) {
            $deployer = $customDeployer;
        } else {
            $deployer = $this->loadedDeployer;
        }

        // Is previously cached?
        $cacheKey = $this->computeCacheKey($asset->getFullPath(), $filters, $deployer);
        $cacheValue = $this->loadedCacheAdapter->get($cacheKey);

        if ($cacheValue !== false) {
            $asset->setOutputUrl($cacheValue);

            return $asset;
        }

        // If there is any different extension, then set it first
        $this->applyFilterOutputExtension($filters, $asset);

        // Is previously deployed?
        if (isset($this->deployersInstances[$deployer]) && $this->deployersInstances[$deployer]->isPreviouslyDeployed($asset)) {
            // Cache the result
            $cacheValue = $asset->getOutputUrl();
            $this->loadedCacheAdapter->save($cacheKey, $cacheValue, $this->cacheTtl);

            return $asset;
        }

        // Pass the asset through all filters.
        $this->filterAsset($filters, $asset);

        // All set! Let's deploy now.
        $this->deployAsset($deployer, $asset);

        // Cache the result
        $cacheValue = $asset->getOutputUrl();
        $this->loadedCacheAdapter->save($cacheKey, $cacheValue, $this->cacheTtl);

        return $asset;
    }
public function work ( $ file , $ customFilters = null , $ customDeployer = null ) { // Create the Asset instance foreach ( $ this -> assetsSource as $ source ) { if ( is_file ( $ source . DIRECTORY_SEPARATOR . $ file ) ) { $ asset = $ this -> objectsFactory -> buildAsset ( $ source . DIRECTORY_SEPARATOR . $ file ) ; } } if ( ! isset ( $ asset ) ) { $ asset = $ this -> objectsFactory -> buildAsset ( $ file ) ; } // Assemble the $filters array of fully qualified filters class names if ( is_array ( $ customFilters ) ) { $ filters = $ customFilters ; } else { $ ext = $ asset -> getExtension ( ) ; $ filters = isset ( $ this -> filters [ $ ext ] ) ? $ this -> filters [ $ ext ] : array ( ) ; } // Decide which deployer will be used. if ( is_string ( $ customDeployer ) ) { $ deployer = $ customDeployer ; } else { $ deployer = $ this -> loadedDeployer ; } // Is previously cached? $ cacheKey = $ this -> computeCacheKey ( $ asset -> getFullPath ( ) , $ filters , $ deployer ) ; $ cacheValue = $ this -> loadedCacheAdapter -> get ( $ cacheKey ) ; if ( $ cacheValue !== false ) { $ asset -> setOutputUrl ( $ cacheValue ) ; return $ asset ; } // If there is any different extension, then set it first $ this -> applyFilterOutputExtension ( $ filters , $ asset ) ; // Is previously deployed? if ( isset ( $ this -> deployersInstances [ $ deployer ] ) && $ this -> deployersInstances [ $ deployer ] -> isPreviouslyDeployed ( $ asset ) ) { // Cache the result $ cacheValue = $ asset -> getOutputUrl ( ) ; $ this -> loadedCacheAdapter -> save ( $ cacheKey , $ cacheValue , $ this -> cacheTtl ) ; return $ asset ; } // Pass the asset through all filters. $ this -> filterAsset ( $ filters , $ asset ) ; // All set! Let's deploy now. $ this -> deployAsset ( $ deployer , $ asset ) ; // Cache the result $ cacheValue = $ asset -> getOutputUrl ( ) ; $ this -> loadedCacheAdapter -> save ( $ cacheKey , $ cacheValue , $ this -> cacheTtl ) ; return $ asset ; }
Processes and deploys an asset and returns an Asset instance
with modified properties, according to used filters and deployers.

@param string $file file name to be searched through "assets_source"
@param null|array $customFilters Overrides "filter" setting
@param null|string $customDeployer Overrides the loaded deployer

@return Asset The created Asset instance
Processes and deploys an asset and returns an Asset instance with modified properties according to used filters and deployers .