/** @dataProvider inputDataProvider */ public function testInput($input, $expected) { $actual = $this->args->decode($input); foreach($expected as $key => $value) { $this->assertEquals($value, $actual[$key]); } }
/** * * @param closure $callback */ public function notify($callback) { Args::callBackArgs($callback, 1, 'callback'); foreach ($this->listeners as $listener) { $callback($listener); } }
/** * Saves a resource to the cache. * @param type $name * @param type $resource * @param type $scope */ public static function saveResource($name, $resource, $scope) { Args::isString($name, 'name'); $instance = self::get(); $dir = $instance->getDirectoryForScope($scope); $instance->internalSaveResource($dir, $name, $resource); }
/** * * @param number $minimum * @param number $maximum */ public function __construct($minimum, $maximum) { Args::isNumeric($maximum, 'maximum'); Args::isNumeric($minimum, 'minimum'); $this->minimum = $minimum; $this->maximum = $maximum; }
public function run() { $rewrites = Args::get('rewrites', Args::argv); if ($rewrites && $rewrites == "nginx") { self::set_rules($rules); echo "== Start Nginx Rewrites" . PHP_EOL; $nginx_filename = Args::get('filename', Args::argv); $nginx_folder = Args::get('folder', Args::argv); if (!$nginx_filename || !$nginx_folder) { echo "Missing arguments"; exit(0); } self::save_nginx_rewrites($nginx_filename); if (!self::check_nginx_config($nginx_filename, $nginx_folder)) { echo "Nginx config is outdated, please run the following commands:" . PHP_EOL; echo "cp " . $nginx_filename . " " . $nginx_folder . $nginx_filename . PHP_EOL; echo "/etc/init.d/nginx restart" . PHP_EOL; } echo "== End Nginx Rewrites" . PHP_EOL; exit(0); } $generate_default_rules = Args::get('generate-default-rules', Args::argv); if ($generate_default_rules) { global $dirs; global $current_hostname; self::set_userland($dirs[$current_hostname]['userland']); echo "== Updating Default Rules..." . PHP_EOL; RocketPath::generate_default_rules(); RocketPath::write_default_rules_to_file('rules.default.php'); echo '== Default Rules Updated !' . PHP_EOL; exit(0); } }
/** * * @param string $name * @param closure $newMethod */ public function __construct($name, $newMethod) { Args::isString($name, 'name'); Args::callBackArgs($newMethod, 1, 'newMethod'); $this->name = $name; $this->newMethod = new SerializableClosure($newMethod); }
public function __construct($event, $callback) { parent::__construct(); Args::isString($event, 'event'); Args::callBackArgs($callback, 1, 'callback'); $this->event = $event; $this->callback = $callback; }
public function __construct($id, Pageable $pageable, $page) { parent::__construct($id, function () { }); Args::isNumeric($page, 'page'); $this->pageable = $pageable; $this->page = $page; }
public function __construct(Identifier $pageIdentifier, Identifier $loginPage) { Args::identifierOf($pageIdentifier, WebPage::getIdentifier(), 'pageIdentifier'); Args::identifierOf($loginPage, WebPage::getIdentifier(), 'loginPage'); $this->pageAuthIdentifier = $pageIdentifier; $this->loginPageIdentifier = $loginPage; PiconApplication::get()->getSecuritySettings()->setComponentNotAuthorisedListener(new DirectToPageComponentNotAuthorisedListener($loginPage)); }
protected function onRender() { $components = $this->getRenderArray(); Args::isArray($components, 'getRenderArray return value'); foreach ($components as $index => $component) { $this->renderChild($component); } }
public function __construct($id, $callback, $callDecorator = null) { parent::__construct($id); Args::callBackArgs($callback, 1, 'callback'); $this->eventBehaviour = new AjaxEventBehaviour('onclick', $callback); $this->add($this->eventBehaviour); $this->callback = $callback; }
public function dispatchEvent($eventName, Args $eventArgs = null) { if (isset($this->_listeners[$eventName])) { $eventArgs = $eventArgs === null ? Args::getEmptyInstance() : $eventArgs; foreach ($this->_listeners[$eventName] as $listener) { $listener->{$eventName}($eventArgs); } } }
/** * * @param type $name * @param type $function * @param ... args the names of the arguments the javascript function should take */ public function __construct($name, $function) { parent::__construct($name); Args::isString($function, 'function'); $this->function = $function; $args = func_get_args(); for ($i = 2; $i < count($args); $i++) { array_push($this->args, $args[$i]); } }
/** * * @param Tab $tab * @param closure $newMethod */ public function addTab($tab, $newMethod = null) { if ($tab instanceof Tab) { array_push($this->tabs, $tab); } else { Args::isString($tab, 'tab'); Args::callBackArgs($newMethod, 1, 'newMethod'); array_push($this->tabs, new Tab($tab, $newMethod)); } }
public function __construct($id, $columnId, $columns, $callback = null, $model = null) { parent::__construct($id, $model); if ($callback != null) { Args::callBackArgs($callback, 1, 'callback'); } $this->columns = $columns; $this->columnId = $columnId; $this->callback = $callback; }
/** * * @param closure $valueCallable * @param closure $displayCallable */ public function __construct($valueCallable = null, $displayCallable = null) { if ($valueCallable != null) { Args::callBackArgs($valueCallable, 2, 'valueCallable'); } if ($displayCallable != null) { Args::callBackArgs($displayCallable, 2, 'displayCallable'); } $this->displayCallable = $displayCallable; $this->valueCallable = $valueCallable; }
public function query($sql, RowMapper $mapper, $arguments = null) { $records = array(); $sql = $this->prepareArgs($sql, $arguments); $results = $this->driver->query($sql, $this->getConnection()); while ($row = $this->driver->resultSetObject($results)) { $record = $mapper->mapRow($row); Args::notNull($record, 'row mapper return value'); array_push($records, $record); } return $records; }
/** * * @param string $id * @param callback $onSubmit Called when the form is valid * @param callback $onError Called when the form is not valid */ public function __construct($id, $onSubmit = null, $onError = null) { parent::__construct($id); if ($onSubmit != null) { Args::callBack($onSubmit, 'onSubmit'); } if ($onError != null) { Args::callBack($onError, 'onError'); } $this->onSubmit = $onSubmit; $this->onError = $onError; }
/** * * @param type $name * @param type $function * @param ... args the names of the arguments the javascript function should take */ public function __construct($name, $callback, $function) { parent::__construct($name); Args::isString($function, 'function'); Args::callBackArgs($callback, 1, 'callback'); $this->callback = new SerializableClosure($callback); $this->function = $function; $args = func_get_args(); for ($i = 3; $i < count($args); $i++) { array_push($this->args, $args[$i]); } }
/** * * @param closure $decorator * @param closure $successDecorator * @param closure $failDecorator */ public function __construct($decorator, $successDecorator = null, $failDecorator = null) { Args::callBackArgs($decorator, 1, 'decorator'); if ($successDecorator != null) { Args::callBackArgs($successDecorator, 1, 'successDecorator'); } if ($failDecorator != null) { Args::callBackArgs($failDecorator, 1, 'failDecorator'); } $this->decorator = $decorator; $this->successDecorator = $successDecorator; $this->failDecorator = $failDecorator; }
/** * * @param string $id * @param array $choices * @param Model $model */ public function __construct($id, $choices, ChoiceRenderer $choiceRenderer = null, Model $model = null, $isDisabled = null) { parent::__construct($id, $model); Args::isArray($choices, 'choices'); $this->choices = $choices; if ($choiceRenderer == null) { $choiceRenderer = new ChoiceRenderer(); } $this->choiceRenderer = $choiceRenderer; if ($isDisabled != null) { Args::callBackArgs($isDisabled, 2, 'isDisabled'); $this->isDisabled = $isDisabled; } }
function put_model($args) { Args::label($args, 'route', 'model'); $model =& $this->_model; // XXX: add support for matching based named items - search children rather than keys $fragments = explode('/', $args->route); for ($i = 0; $i < count($fragments); $i++) { if (isset($model[$fragments[$i]]) !== true) { /* create if it doesn't exist */ $model[$fragments[$i]] = array(); } $model =& $model[$fragments[$i]]; } $model = array_replace_recursive($model, $args->model); // XXX: error_log('put_model: '.$args->params[0].' - '.print_r($model, true)); JSON::encode_file($this->_model_file, $this->_model); /* generate site with data */ $this->_teapot->generate($args->route); }
function get_fields(&$args) { Args::label($args, 'route', 'user'); /* first check direct route */ $route = $args->route; if (!isset($this->_schema[$route])) { /* no direct route for this, check for generic */ $fragments = explode('/', $args->route, 2); $route = $fragments[0] . '/*'; error_log($route); if (!isset($this->_schema[$route])) { throw new NotFoundException($args->route . ', invalid route'); } } if ($args->retval == NULL) { $args->retval = array(); } $args->retval = array_merge_recursive($args->retval, $this->_schema[$route]); }
public function __construct($event, $onEvent, $onSubmit, $onError) { Args::callBackArgs($onEvent, 1, 'onEvent'); if ($onSubmit != null) { Args::callBackArgs($onSubmit, 1, 'onSubmit'); } if ($onError != null) { Args::callBackArgs($onError, 1, 'onError'); } $self = $this; parent::__construct($event, function ($target) use($self, $onEvent, $onSubmit, $onError) { $formComponent = $self->getComponent(); $formComponent->processInput(); $onEvent($target); if ($formComponent->isValid() && $onSubmit != null) { $onSubmit($target); } if (!$formComponent->isValid() && $onError != null) { $onError($target); } }); }
public function __construct($event, $onSubmit = null, $onError = null, $form = null) { $self = $this; parent::__construct($event, function ($target) use($self) { $self->setAjaxRequestTarget($target); $self->getForm()->process($self); }); if ($onSubmit != null) { Args::callBackArgs($onSubmit, 1, 'onSubmit'); } if ($onError != null) { Args::callBackArgs($onError, 1, 'onError'); } $this->onSubmit = $onSubmit; $this->onError = $onError; if ($form != null) { if ($form instanceof Form) { $this->form = $form; } else { throw new \InvalidArgumentException('$form must be an instance of Form'); } } }
/** * * @param array $object */ public function __construct(&$object) { Args::isArray($object, 'object'); $this->object =& $object; }
public function __construct($heading, $callback) { Args::callBackArgs($callback, 2, 'callback'); $this->callback = $callback; }
public function setRevert($revert) { Args::isBoolean($revert, 'revert'); $this->getOptions()->add(new BooleanOption('revert', $revert)); }
<?php ini_set("include_path", ini_get("include_path") . ":../lib/"); require_once "Args.class.php"; $a = new Args(); $file = $a->flag("file"); if ($file === FALSE) { printHelp(); } $document = new DomDocument(); if (!is_readable($file)) { print "{$file} can not be read.\n"; exit(1); } if ($document->load($file) === FALSE) { print "Failed to load service definition\n"; exit(1); } $typeNodes = $document->getElementsByTagName("type"); $methodNodes = $document->getElementsByTagName("method"); $serviceNode = $document->documentElement; $serviceName = $serviceNode->attributes->getNamedItem("name")->value; $serviceUrl = $serviceNode->attributes->getNamedItem("url")->value; $serviceNS = str_replace(".", "\\", $serviceNode->attributes->getNamedItem("ns")->value); //print "/*\n"; //print "Service name: " . $serviceName . "\n"; //print "Service URL: " . $serviceUrl . "\n"; //print "Service NS: " . $serviceNS . "\n"; //print "Found " . $typeNodes->length . " type definitions\n"; //print "Found " . $methodNodes->length . " method definitions\n"; //print "*/\n\n";
public function flag($name) { return isset($this->flags[$name]) ? $this->flags[$name] : false; } } function usage() { echo "commands: -s {stop} | -p file {photo} | -d {desktop (mac only)}\n"; echo "php " . $GLOBALS['argv'][0] . " -h hostname[:port] command\n"; } function waitforuser() { echo 'Press return to quit'; fgets(STDIN); } $args = new Args(); $host = $args->flag('h'); if ($host == null || $host == '' || $host === false) { usage(); exit(1); } else { $host = split(':', $host); if (count($host) > 1) { $airplay = new AirPlay($host[0], $host[1]); } else { $airplay = new AirPlay($host[0]); } if ($args->flag('s')) { $airplay->stop(); } elseif ($file = $args->flag('p')) { $airplay->photoFile($file);