public function middleware($alias, $options = []) { $middlewares = []; # get previously assigned aliases if (di()->has('middleware_aliases')) { $middlewares = di()->get('middleware_aliases')->toArray(); } $append_alias = true; $action_name = dispatcher()->getActionName(); if (isset($options['only'])) { if (in_array($action_name, $options['only']) === false) { $append_alias = false; } } if (isset($options['except'])) { if (in_array($action_name, $options['except'])) { $append_alias = false; } } if ($append_alias === true) { $middlewares[] = $alias; } di()->set('middleware_aliases', function () use($middlewares) { return new Config($middlewares); }); }
public function testHelpersFacade() { $this->assertInstanceOf(\Clarity\Support\Auth\Auth::class, auth()); $this->assertInstanceOf(\Phalcon\Config::class, config()); $this->assertInstanceOf(\Phalcon\Mvc\Dispatcher::class, dispatcher()); $this->assertInstanceOf(\Phalcon\Filter::class, filter()); $this->assertInstanceOf(\Phalcon\Flash\Direct::class, flash()->direct()); $this->assertInstanceOf(\Phalcon\Flash\Session::class, flash()->session()); $this->assertInstanceOf(\League\Flysystem\Filesystem::class, flysystem()); $this->assertInstanceOf(\League\Flysystem\MountManager::class, flysystem_manager()); $this->assertInstanceOf(\Clarity\Support\Redirect\Redirect::class, redirect()); $this->assertInstanceOf(\Clarity\Support\Phalcon\Http\Request::class, request()); $this->assertInstanceOf(\Phalcon\Http\Response::class, response()); $this->assertInstanceOf(\Phalcon\Mvc\Router::class, route()); $this->assertInstanceOf(\Phalcon\Security::class, security()); $this->assertInstanceOf(\Phalcon\Tag::class, tag()); $this->assertInstanceOf(\Phalcon\Mvc\Url::class, url()); $this->assertInstanceOf(\Phalcon\Mvc\View::class, view()); # getting an error, will check later on $this->assertInstanceOf(\Monolog\Logger::class, logger()); # adapter base functions // $this->assertInstanceOf(, cache()); // $this->assertInstanceOf(, db()); // $this->assertInstanceOf(, queue()); // $this->assertInstanceOf(, session()); $this->assertContains(url()->getBaseUri() . 'auth/login', route('showLoginForm')); $this->assertInstanceOf(\Phalcon\Mvc\View::class, view('welcome')); }
define("BYPASS_INSTANCE_CHECK", true); require_once "../../server/bootstrap.php"; $response = null; function dispatcher() { global $response; switch ($_GET["action"]) { case "mod": $response = json_decode(InstanciasController::Editar($_GET["id"], $_GET["activa"], $_GET["descripcion"], $_GET["token"], $_GET["status"])); break; default: return; } } if (isset($_GET["action"])) { dispatcher(); } $p = new JediComponentPage("Editar instancia"); $p->requireParam("id", "GET", "Esta instancia no existe.", "InstanciasController::Detalles"); $instancia = InstanciasController::Detalles($_GET["id"]); $p->partialRender(); ?> <h2>Editar Instancia</h2> <table style = "width:100%;"> <form name = "form1" action = "instancias.editar.php"> <tr> <td>Token</td><td><input type = "text" name = "token" value = "<?php echo $instancia["instance_token"]; ?>
* * V1.05 */ function __autoload($class) { @(include './model/' . $class . '.php'); @(include './controller/' . $class . '.php'); @(include './sfdc/' . $class . '.php'); } session_start(); $debug = 0; //debug mode $errors = array(); $messages = null; //debug($client->__getFunctions()); isset($_REQUEST['type']) ? dispatcher($_REQUEST['type']) : ''; function addErrors($field, $msg) { global $errors; $error['field'] = $field; $error['msg'] = $msg; $errors[] = $error; } function dispatcher($type) { switch ($type) { case 'LoginAttempt': loginAttempt(); break; case 'GetInitialCart': getInitialCart();
function triggerEvent($event, $args = []) { return dispatcher()->trigger($event, $args, 'handle'); }
public function ignoreQueryListening() { if ($this->queryPreparedListener) { dispatcher()->ignore(Query::class . '.prepared', $this->queryPreparedListener); } }
<?php $article_id = $_POST['article_id']; dispatcher($article_id); function dispatcher($id) { include 'public/articles/' . $id . '.html'; }
/** * @return null|string */ public function toHTML() { if ($this->html) { return $this->html; } $listened = false; if (!dispatcher()->hasListeners('htmlbuilder.decorate')) { registerEvent(new DecorationRequested()); registerEvent(new PreDecorationRequested()); triggerEvent('htmlbuilder.predecorate', ['context' => $this->createContext()]); $this->triggerPreBuildOnChildren(); triggerEvent('htmlbuilder.decorate', ['context' => $this->createContext()]); $listened = true; } // store html so it doesnt get executed again $this->html = $this->buildElement(); if ($this->siblings) { $this->html .= $this->buildFromArray($this->siblings); } if ($this->decoratedParent) { $this->html = $this->decoratedParent->addChild($this->html)->toHTML(); } if ($listened) { dispatcher()->destroy('htmlbuilder.decorate'); dispatcher()->destroy('htmlbuilder.predecorate'); } return $this->html . "\n"; }