commandsPaths[$path] = trim($namespace, '\\'); return $this; } public function chdir($directory) { chdir($directory); return $this; } public function loadCommands() { foreach ($this->commandsPaths as $path => $namespace) { $finder = new Finder(); $finder->name('*Command.php')->in($path); foreach ($finder as $file) { $className = $namespace.'\\'.str_replace('.php', '', $file->getFilename()); try { $reflexion = new ReflectionClass($className); if ($reflexion->isInstantiable()) { $command = new $className(); $this->addCommands(array( $command, )); } } catch (ReflectionException $e) { } } } return $this; } public function setConfigLoader(ConfigLoader $configLoader) { $this->configLoader = $configLoader; return $this; } public function getConfigLoader() { return $this->configLoader; } public function buildUrl($uri = '') { return sprintf('https://www.livecoding.tv/%s', ltrim($uri, '/')); } public function buildStreamUrl($stream) { return sprintf( 'rtmp://eumedia1.livecoding.tv:1935/livecodingtv/%s', trim($stream, '/') ); } public function getPlayer($stream) { $stream = $this->buildStreamUrl($stream); return str_replace( '%stream%', escapeshellarg($stream), $this->getConfigLoader()->getConfig()['player']['command'] ); } public function isDebugMode() { return $this->getConfigLoader()->getConfig()['debug']; } public function getContainer() { if (null !== $this->container) { return $this->container; } return $this->container = new Container(); } }