/** * getAsset - render assets of a given type for a package * * @param string $name * @param sfDynamicsAssetCollectionDefinition $package * @param string $type * @return string */ public function getAsset($name, Dynamics_Configuration_Definition_AssetCollection $package, $type) { $extension = Dynamics::getExtensionFromType($type); $getAssets = 'get' . ucfirst($type) . 's'; if (count($assets = $package->{$getAssets}())) { $paths = $package->getPaths($this->configuration->getGlobalAssetPaths()); if ($this->configuration->isCacheEnabled()) { $cache = $this->configuration->getCacheService(); $cacheKey = $cache->generateKey($package, $type); if ($cache->has($cacheKey)) { if ($this->configuration->isCacheUpToDateCheckEnabled()) { if ($cache->isStillUpToDate($package, $type, $cacheKey)) { $result = $cache->get($cacheKey); } } else { $result = $cache->get($cacheKey); } } } // still no result? let's build it! if (!isset($result)) { $result = $this->configuration->getConcatenatedAssetFilterChainFor($type)->filter($this->getConcatenatedAssets($package, $paths, $assets)); if ($this->configuration->isCacheEnabled()) { $cache->set($cacheKey, $result); } } return $result; } else { return ''; } }
public function __construct(sfEventDispatcher $dispatcher) { $this->dispatcher = $dispatcher; // TODO $this->dispatcher->connect('task.cache.clear', array('sfDynamicsCache', 'clearSuperCache')); $this->configuration = new sfDynamicsConfiguration(array(Dynamics_Configuration::ROUTING_SERVICE_CLASS => 'sfDynamicsRouting', Dynamics_Configuration::WEB_DIR => sfConfig::get('sf_web_dir'), Dynamics_Configuration::CACHE_SERVICE_CLASS => 'sfDynamicsSymfonyCacheAdapter', Dynamics_Configuration::CACHE_SERVICE_OPTIONS => array(array('implementation' => 'Dynamics_Cache_NoCache', 'cache_dir' => '/tmp')))); parent::__construct($this->configuration); }
public function run($name, $parameters = array()) { list($name, $extension) = $this->parseName($name); $package = $this->configuration->getPackage($name); $type = Dynamics::getTypeFromExtension($extension); $this->{'pre' . ucfirst($type)}($package); return $this->configuration->getRendererService()->getAsset($name, $package, $type, $extension); }
function forEveryN($n, $value, $fn) { if ($value % $n == 0) { $fn($value); } } $currentDate = $argv[1]; $thisDate = DateTime::createFromFormat('Y-m-d', $currentDate); $lastDate = DateTime::createFromFormat('Y-m-d', $currentDate)->sub(new DateInterval('P7D')); $thisDatePrev = DateTime::createFromFormat('Y-m-d', $currentDate)->sub(new DateInterval('P14D')); $lastDatePrev = DateTime::createFromFormat('Y-m-d', $currentDate)->sub(new DateInterval('P21D')); $this_week = Dynamics::getIsoWeek($thisDate); $this_week_year = Dynamics::getYear($thisDate); $last_week = Dynamics::getIsoWeek($lastDate); $last_week_year = Dynamics::getYear($lastDate); $crm = new Dynamics($last_week, $this_week, $last_week_year, $this_week_year); $salesteam = []; $won_detail = []; $open_detail = []; $opps = []; // C:\Users\roger\Documents\Programming\php\CRMApp\html\data\week-46\opps-week-46.csv // C:\Users\roger\Documents\Programming\php\CRMApp\html\data\week-46\opps-week-46.csv $csvFile = "html/data/week-{$this_week}/opps-week-{$this_week}.csv"; $jsonFile = "html/data/week-{$this_week}/opps-week-{$this_week}.js"; if (FALSE === file_exists($csvFile)) { throw new \Exception("input file {$csvFile} not found."); die; } //$csvFile = 'crm.csv'; $inputFile = fopen($csvFile, "r"); $rows = 0;