/** * Modifies the user agent * * @param Brawler_Plugin_Notification $notification * @return Brawler_Plugin_Notification */ public function _initCurl(Brawler_Plugin_Notification $notification) { if ($notification instanceof Brawler_Plugin_Notification_Post) { if (Brawler_Console::getArgument('a')) { curl_setopt($notification->getReturn(), CURLOPT_USERAGENT, Brawler_Console::getArgument('a')->getValue()); } } }
/** * Parses the given arguments * * @return void * @throws Brawler_Console_Exception */ public static function _parseArguments() { self::$_arguments = new Brawler_Console_Argument_List(); $args = new ArrayObject($_SERVER['argv']); $args->offsetUnset(0); $i = $args->getIterator(); while ($i->valid()) { if (substr($i->current(), 0, 1) == '-') { // parse argument self::_parseArgument($i->current()); } else { // invalid call throw new Brawler_Console_Exception('Invalid call'); } $i->next(); } }
/** * Reads the plugin depending on configuration * * @return Brawler_Plugin_List */ protected static function _getPlugins() { if (!Brawler_Console::getArgument('p')) { $directory = realpath('src/Plugins/'); } else { $directory = Brawler_Console::getArgument('p')->getValue(); } if (Brawler_Console::getArgument('P')) { $directory .= PATH_SEPARATOR . Brawler_Console::getArgument('P')->getValue(); } // Append Plugin Directorys to include Path set_include_path(get_include_path() . PATH_SEPARATOR . $directory); $dirs = split(PATH_SEPARATOR, $directory); $list = new Brawler_Plugin_List(); foreach ($dirs as $dir) { self::scanPlugins($dir, $list); } return $list; }
/** * Checks whether a route arguments vakue matches to the required * * @param Brawler_Router_Argument $routeArgument * @return Bool */ protected static function _checkSpecificValue(Brawler_Router_Argument $routeArgument) { if ($routeArgument->getSpecificValue()) { if (self::_checkValue($routeArgument)) { $argument = Brawler_Console::getArgument($routeArgument->getFlag()); return $argument->getValue() == $routeArgument->getSpecificValue(); } } return true; }
/** * Filters foreign host urls * * @param Array $urls * @return Array */ protected function _filterForeignHostUrls($urls) { $return = array(); $curl = Brawler_Console::getArgument('r')->getValue(); foreach ($urls as $url) { if (parse_url($url, PHP_URL_HOST) == parse_url($curl, PHP_URL_HOST)) { $return[] = $url; } } return $return; }