/** * Iterate over the PHP files available in the component's folder to list * all the page this factory is capable of serving. Note that we skip * "component", which is the component class, not a page. * * @return array */ public function listAvailablePages() { $pages = array(); $files = glob($this->getPath() . '/*.php'); $namespace = $this->getComponentNamespace(); foreach ($files as $file) { $urlName = $this->inflector->hyphenize(basename($file, '.php')); $className = $namespace . '\\' . $this->inflector->camelize($urlName); if ('component' !== $urlName) { $pages[] = new Page($urlName, $file, $className); } } return $pages; }
/** * Apply the filter to the supplied Select object. * * @param Select $select * @param string $conditionSetName * @param array $queryVars * @return Select * @throws InvalidOperator * @throws MissingQueryVar */ public function apply(Select $select, $conditionSetName, array $queryVars) { $this->validate($queryVars); $operator = $queryVars['comp']; $start = null; $end = null; $startObj = null; $startIso = null; $endObj = null; $endIso = null; if ($this->truncateTimestamps) { $format = 'Y-m-d'; } else { $format = 'Y-m-d G:i:s'; } if ($queryVars['start']) { try { $startObj = new DateTime($queryVars['start']); $startIso = $startObj->format($format); } catch (Exception $e) { // If we get input we can't parse, we just throw it out } } if ($queryVars['end']) { try { $endObj = new DateTime($queryVars['end']); $endIso = $endObj->format($format); } catch (Exception $e) { // If we get input we can't parse, we just throw it out } } // If the second input is greater than the first, swap them for the user if ($startObj && $endObj && $endObj < $startObj) { $swapEndIso = $endIso; $endIso = $startIso; $startIso = $swapEndIso; } $methodName = 'filter' . $this->inflector->camelize($operator); return $this->{$methodName}($select, $conditionSetName, $startIso, $endIso); }