/** * Register the service provider. * * @return void */ public function register() { $this->app['parameters'] = $this->app->share(function ($app) { return new Parameters(); }); // Find the default Controller class of the current Laravel application $controllerClass = $this->app['config']->get('authority-controller.controllerClass', 'Illuminate\\Routing\\Controller'); $this->app->resolving(function ($object) use($controllerClass) { // Check if the current $object class is a Controller class and if it responds to paramsBeforeFilter method if (is_a($object, $controllerClass) && respond_to($object, 'paramsBeforeFilter')) { // Fill $params properties of the current controller $this->app['parameters']->fillController($object); } }); $this->app['authority'] = $this->app->share(function ($app) { $user = $app['auth']->user(); $authority = new Authority($user); $fn = $app['config']->get('authority-controller.initialize'); $serializer = new Serializer(); if (is_string($fn)) { $fn = $serializer->unserialize($fn); } if ($fn) { $fn($authority); } return $authority; }); $this->app->bind('Efficiently\\AuthorityController\\ControllerResource', function ($app, $parameters) { list($controller, $resourceName, $resourceOptions) = $parameters; return new ControllerResource($controller, $resourceName, $resourceOptions); }); }
/** * Executes the current command * * @param use Symfony\Component\Console\Input\InputInterface $input * @param use Symfony\Component\Console\Input\OutputIterface $output * * @return null|int null or 0 if everything went fine, or an error code */ protected function execute(InputInterface $input, OutputInterface $output) { $args = []; $this->arguments = $input->getArguments(); parse_str($this->arguments['closure'], $args); $serializer = new Serializer(); call_user_func_array($serializer->unserialize($args[0]), []); }
/** * @param string $serializedJob * @return callable */ public static function deserialize($serializedJob) { $serializedJob = openssl_decrypt($serializedJob, self::$encryptMethod, self::$encryptMethod, false, self::$encryptIV); if (self::endswith($serializedJob, self::$serializedTag)) { $serializedJob = rtrim($serializedJob, self::$serializedTag); $serializer = new Serializer(); $serializedJob = $serializer->unserialize($serializedJob); } return $serializedJob; }
protected function run($serializedCallable) { $serializer = new Serializer(); $callable = $serializer->unserialize($serializedCallable); if (is_callable($callable)) { $callable(); } else { throw new \InvalidArgumentException('Invalid serialized callable'); } }
/** * Run the passed closure as received via command line. * * @param function $closure * @return void */ public static function pickup($closure) { // serializer $serializer = new Serializer(); // unpack $unpacked = unserialize(base64_decode($closure)); // unserialize $unserialized = $serializer->unserialize($unpacked); // process $unserialized(); }
/** * Prepares the controller closures to be unserialized */ public function __wakeup() { $serializer = new Serializer(new AstAnalyzer()); foreach ($this->routes as $method => $routesByMethod) { /** @var ParsedRoute $route */ foreach ($routesByMethod as $route) { if ($route->usesClosure()) { $route->setControllerClosure($serializer->unserialize($route->getController())); } } } }
function route($slug) { //Load calleble object via slug $route = $this->load_route($slug); if ($route) { $serializer = new Serializer(); $closure = $serializer->unserialize($route->closure); $params = explode('/', $slug); array_shift($params); $closure($slug, $params); } //Run calleble object render function }
/** * Set the currently logged in user for the application and load his authorization rules * * @param Illuminate\Contracts\Auth\Authenticatable $user * @param Closure $fn Function callback who contains Authority rules. * By default it loads the default config file: 'config/authority-controller.php'. * @return Authority */ protected function loginAs(Illuminate\Contracts\Auth\Authenticatable $user, $fn = null) { $this->app['auth']->login($user); $this->app['authority'] = new Authority($user); $authority = $this->app->make('authority'); $fn = $fn ?: $this->app['config']->get('authority-controller.initialize'); $serializer = new Serializer(); if (is_string($fn)) { $fn = $serializer->unserialize($fn); } if ($fn) { $fn($authority); } return $authority; }
/** * Response sender message * * @param $nodes * @param null $lead_id */ public function response($nodes, $lead_id = null) { if (is_null($lead_id)) { $lead_id = $this->conversation->get('lead_id'); } foreach ($nodes as $node) { /** New wait */ if (!empty($node->wait)) { $this->storage->set($lead_id, '_wait', $node->wait); } // Backward compatibility if (array_key_exists('type', $node->answers)) { $node->answers = [$node->answers]; } foreach ($node->answers as $answer) { /** Process dynamic content */ if (isset($answer['type'])) { // Backward compatibility if (isset($answer['callback'])) { $answer['content'] = $answer['callback']; } if (giga_match('%SerializableClosure%', $answer['content'])) { $answer['content'] = $this->serializer->unserialize($answer['content']); } $return = DynamicParser::parse($answer); // If the callback return, we'll send that message to user. if ($return != null || !empty($return)) { $answer = $this->model->parseWithoutSave($return); // Answer == 0 means that answers is already parsed and it's a single message. if ($answer != false) { $this->request->sendMessages($answer); } else { $this->request->sendMessage($return); } continue; } } $this->request->sendMessage($answer); } } }
static function execute($number = 5) { if (!is_numeric($number)) { throw new Exception('Number must be numeric'); } $callables = R::findAll('queueitem', 'status = "open" ORDER BY id DESC LIMIT ' . $number); $c = 0; foreach (array_values($callables) as $index => $calleble) { $c++; if ($calleble->done) { $c--; continue; } if ($c >= $number) { break; } $serializer = new Serializer(); $closure = $serializer->unserialize($calleble->callser); //// $calleble->status = 'busy'; // R::store($calleble); $closure(); $calleble->status = 'done'; $calleble->done = true; $calleble->doneat = time(); R::store($calleble); } return; }