public function __construct(Table $table, ActivityLog $activityLog = null, Inflector $inflector = null) { $this->table = $table; $this->inflector = $inflector ?: Pimple::getResource('inflector'); $tableName = $table->getTableName(); $inflectedName = $this->inflector->singularize($this->inflector->hyphenize($tableName)); if (!$tableName) { $className = get_class($table); throw new Exception("Cannot create activity log handle for {$className} because no table name is set."); } $this->setActivityLog($activityLog ?: Pimple::getResource('activity-log'))->setName($inflectedName)->setModel($table)->addAlias($tableName); parent::__construct(); }
/** * 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; }