/**
  * {@inheritdoc}
  * @return Model
  */
 public function findBy(array $where = [])
 {
     if ($where === []) {
         return forward_static_call_array([get_class($this->getEloquentModel()), 'all']);
     }
     return forward_static_call_array([get_class($this->getEloquentModel()), 'where'], $where);
 }
Example #2
0
 public static function __callStatic($name, $arguments)
 {
     echo "{$name}(" . implode(', ', $arguments) . ") = ";
     $ret = forward_static_call_array($name, $arguments);
     echo print_r($ret, true) . "\n";
     return $ret;
 }
Example #3
0
 public static function details($_model = null)
 {
     $module = static::$module;
     $modeler = $module::model()->modeler;
     $_model = $_model == null ? forward_static_call_array(array($modeler, 'model'), array()) : forward_static_call_array(array($modeler, 'model'), array($_model));
     $_o = (object) null;
     $_o->size = 'large';
     $_o->icon_type = 'menu-icon';
     $_o->icon_background = 'atom-icon-background';
     $_o->menu = (object) null;
     $_o->menu->items = self::modelOperationsMenuItems();
     $_o->head = 'Package Details';
     $_o->body = array('');
     $_o->body[] = (object) array('js' => 'registry.setContext({card:\'cards/package/details\',collection:\'packages\',node:\'' . $_model->id . '\'});');
     $_o->body[] = CardKitHTML::sublineBlock('Name');
     $_o->body[] = DOMElementKitJS::loadComponentHere(DOMElementKitJS::xhrCallObject('forms/package/name', array($_model->id)), $_model->name, 'settings');
     $_o->body[] = CardKitHTML::sublineBlock('Package Sequode');
     $_o->body[] = $_model->sequode_id != 0 && \Sequode\Application\Modules\Sequode\Modeler::exists($_model->sequode_id, 'id') ? DOMElementKitJS::loadComponentHere(DOMElementKitJS::xhrCallObject('forms/package/packageSequode', array($_model->id)), \Sequode\Application\Modules\Sequode\Modeler::model()->name, 'settings') : ModuleForm::render(static::$registry_key, 'packageSequode')[0];
     $_o->body[] = CardKitHTML::sublineBlock('Package Token');
     $_o->body[] = $_model->token;
     $_o->body[] = CardKitHTML::sublineBlock('<a target="_blank" href="/source/' . $_model->token . '">Download</a>');
     $_o->body[] = CardKit::nextInCollection((object) array('model_id' => $_model->id, 'details_route' => 'cards/package/details'));
     if (\Sequode\Application\Modules\Account\Authority::isSystemOwner()) {
         $_o->body[] = CardKitHTML::modelId($_model);
     }
     return $_o;
 }
Example #4
0
 /**
  * Returns the implementation implementation registered with the Facade.
  *
  * @return Xaamin\Whatsapi\Contracts\WhatsapiInterface
  */
 public static function instance()
 {
     if (!static::$instance) {
         static::$instance = forward_static_call_array(array(get_called_class(), 'create'), func_get_args());
     }
     return static::$instance;
 }
 public static function updateLastSignIn($time = false, $_model = null)
 {
     $modeler = static::$modeler;
     $_model == null ? forward_static_call_array(array($modeler, 'model'), array()) : forward_static_call_array(array($modeler, 'model'), array($_model));
     $modeler::model()->updateField($time === false ? time() : $time, 'last_sign_in');
     return $modeler::model();
 }
 public static function delete($_model = null)
 {
     $modeler = static::$modeler;
     $_model == null ? forward_static_call_array(array($modeler, 'model'), array()) : forward_static_call_array(array($modeler, 'model'), array($_model));
     $modeler::model()->delete($modeler::model()->id);
     return $modeler::model();
 }
Example #7
0
 /**
  * Returns the Sentry instance registered with the Facade.
  *
  * @return \Cartalyst\Sentry\Sentry
  */
 public static function instance()
 {
     if (static::$instance === null) {
         static::$instance = forward_static_call_array([get_called_class(), 'createSentry'], func_get_args());
     }
     return static::$instance;
 }
 /**
  * 处理一个Worker
  * @param string $q queue name
  */
 public function actionWorker($q = "default")
 {
     $retried_at = date('Y-m-d H:i:s');
     $queue = Yii::createObject(['class' => 'wh\\asynctask\\Queue', 'redis' => $this->module->redis]);
     /** @var $identity string */
     $identity = $queue->getWorkerIdentity();
     $logPath = $this->module->getWorkerLogPath();
     FileHelper::createDirectory($logPath);
     $currentDate = date('Y-m-d');
     FileHelper::createDirectory($logPath . '/' . $currentDate);
     $logStderr = "{$logPath}/{$currentDate}/{$q}.stderr.log";
     $data = $queue->pop($q);
     if (!is_null($data)) {
         try {
             $queue->setWorkerStart($identity, $data);
             $this->setProcessTitle($this->module->id . '/worker ' . $data['class'] . ':run(' . implode(', ', $data['args']) . ')');
             forward_static_call_array([$data['class'], 'run'], $data['args']);
         } catch (\Exception $e) {
             if ($data['retry'] && (!isset($data['retry_count']) || $data['retry_count'] < $this->processMaxRetries)) {
                 $queue->setStat(false);
                 $realCommand = sprintf('echo "%s">>%s &', $e->getMessage(), $logStderr);
                 exec($realCommand);
                 $queue->setRetry(['retry' => $data['retry'], 'class' => $data['class'], 'args' => $data['args'], 'enqueued_at' => $data['enqueued_at'], 'error_message' => $e->getMessage(), 'failed_at' => date('Y-m-d H:i:s'), 'job_id' => $data['job_id'], 'queue' => $data['queue'], 'retried_at' => isset($data['retried_at']) ? $retried_at : date('Y-m-d H:i:s'), 'retry_count' => isset($data['retry_count']) ? intval($data['retry_count']) + 1 : 0]);
             }
         }
         $queue->setStat();
         $queue->setWorkerEnd($identity);
     }
 }
 public static function updatePassword($password, $_model = null)
 {
     $modeler = static::$modeler;
     $_model == null ? forward_static_call_array(array($modeler, 'model'), array()) : forward_static_call_array(array($modeler, 'model'), array($_model));
     $modeler::model()->updateField(Hashes::generateHash($password), 'password');
     return $modeler::model();
 }
 public static function packageSequode($_model = null, $user_model = null)
 {
     $module = static::$module;
     $modeler = $module::model()->modeler;
     $_model = $_model == null ? forward_static_call_array(array($modeler, 'model'), array()) : $_model;
     $_user_model = $_user_model == null ? \Sequode\Application\Modules\Account\Modeler::model() : $_user_model;
     $_o = (object) null;
     $values = $where = array();
     $values[] = '{\'value\':\'0\',\'printable\':\'Select Package Sequode\'}';
     $sequodes_model = new \Sequode\Application\Modules\Sequode\Modeler::$model();
     /*
     $where[] = array('field'=>'owner_id','operator'=>'=','value'=>5);
     $where[] = array('field'=>'shared','operator'=>'=','value'=>1);
     $where[] = array('field'=>'package','operator'=>'=','value'=>1);
     $sequodes_model->getAll($where);
     foreach( $sequodes_model->all as $object){
         $values[] = '{\'value\':\''.$object->id.'\',\'printable\':\''.$object->name.'\'}';
     }
     */
     $where = array();
     $where[] = array('field' => 'owner_id', 'operator' => '=', 'value' => $_user_model->id);
     $where[] = array('field' => 'package', 'operator' => '=', 'value' => 1);
     $sequodes_model->getAll($where);
     foreach ($sequodes_model->all as $object) {
         $values[] = '{\'value\':\'' . $object->id . '\',\'printable\':\'' . $object->name . '\'}';
     }
     FormInputModeler::exists('select', 'name');
     $_o->sequode = json_decode(FormInputModeler::model()->component_object);
     $_o->sequode->Label = '';
     $_o->sequode->Values = '[' . implode(',', $values) . ']';
     $_o->sequode->Value = $_model->sequode_id;
     $_o->sequode->Value_Key = 'value';
     $_o->sequode->Printable_Key = 'printable';
     return $_o;
 }
 public static function collections($collection = 'collections', $key = null)
 {
     $module = static::$module;
     if ($collection == 'collections' && isset($module::model()->assets->boot_collections)) {
         $collections = $module::model()->assets->boot_collections;
         echo '{';
         echo "\n";
         foreach ($collections as $loop_key => $collection) {
             if ($loop_key != 0) {
                 echo ",\n";
             }
             echo '"' . $collection . '":';
             echo self::collections($collection);
         }
         echo "\n";
         echo '}';
         return;
     }
     $modules = ModuleRegistry::modules();
     foreach ($modules as $module) {
         if (!empty($module::model()->collections)) {
             if (isset($collection) && in_array($collection, ApplicationRoutes::routes($module::model()->collections))) {
                 forward_static_call_array(array($module::model()->collections, ApplicationRoutes::route($module::model()->collections, $collection)), $key != null ? array($key) : array());
                 return;
             }
         }
     }
     return;
 }
Example #12
0
 /**
  * Closure metódusok futtatása, vagy controller objektumok példányosítása és action futtatása
  */
 public function dispatch($data_array)
 {
     foreach ($data_array as $key => $value) {
         if (isset($value['closure']) && is_callable($value['closure'])) {
             call_user_func_array($value['closure'], $value['params']);
         } elseif (isset($value['controller'])) {
             $this->controller = $value['controller'];
             $this->action = $value['action'];
             $this->params = $value['named_params'];
             $controller_class = $this->controller_namespace . ucfirst($value['controller']);
             if (class_exists($controller_class)) {
                 // first check if is a static method, directly trying to invoke it. if isn't a valid static method, we will try as a normal method invocation.
                 if (call_user_func_array(array(new $controller_class(), $value['action']), $value['params']) === false) {
                     // try call the method as an non-static method. (the if does nothing, only avoids the notice)
                     if (forward_static_call_array(array($controller_class, $value['action']), $value['params']) === false) {
                     }
                 }
             } else {
                 throw new \Exception("Error Processing Request");
             }
         } else {
             throw new \Exception("Error Processing Request");
         }
     }
 }
 public static function updateEmail($email, $_model = null)
 {
     $modeler = static::$modeler;
     $_model == null ? forward_static_call_array(array($modeler, 'model'), array()) : forward_static_call_array(array($modeler, 'model'), array($_model));
     $modeler::model()->updateField($email, 'email');
     return $modeler::model();
 }
 public static function updateComponentSettings($type, $member, $input_object, $_model = null)
 {
     $modeler = static::$modeler;
     $kit = static::$kit;
     $_model == null ? forward_static_call_array(array($modeler, 'model'), array()) : forward_static_call_array(array($modeler, 'model'), array($_model));
     switch ($type) {
         case 'input':
         case 'property':
             $object_member = $type . '_form_object';
             break;
         default:
             return $modeler::model();
     }
     $form_object = json_decode($modeler::model()->{$object_member});
     $component = new \Sequode\Application\Modules\FormInput\Model();
     if (!$component->exists($input_object->Component, 'name')) {
         $component->exists('str', 'name');
     }
     $form_object_member = (object) null;
     $component_form_object = json_decode($component->component_form_object);
     foreach ($component_form_object as $loop_member => $loop_value) {
         if (isset($input_object->{$loop_member})) {
             $form_object_member->{$loop_member} = $input_object->{$loop_member};
         }
     }
     $form_object->{$member} = $form_object_member;
     $modeler::model()->updateField(json_encode($form_object), $object_member);
     self::maintenance();
     return $modeler::model();
 }
Example #15
0
 /**
  * Returns the event dispatcher.
  *
  * @return \Illuminate\Events\Dispatcher
  */
 public static function getDispatcher()
 {
     if (!isset(static::$dispatcher)) {
         static::$dispatcher = function_exists('app') ? app(Dispatcher::class) : forward_static_call_array('Illuminate\\Container\\Container::make', [Dispatcher::class]);
     }
     return static::$dispatcher;
 }
 /**
  * Invokes original method and return result from it
  *
  * @return mixed
  */
 public function proceed()
 {
     if (isset($this->advices[$this->current])) {
         /** @var $currentInterceptor \Go\Aop\Intercept\Interceptor */
         $currentInterceptor = $this->advices[$this->current++];
         return $currentInterceptor->invoke($this);
     }
     // Fill the closure only once if it's empty
     if (!$this->closureToCall) {
         $this->closureToCall = $this->reflectionMethod->getClosure($this->instance);
     }
     // Rebind the closure if instance was changed since last time
     if ($this->previousInstance !== $this->instance) {
         $this->closureToCall = $this->closureToCall->bindTo($this->instance, $this->reflectionMethod->class);
         $this->previousInstance = $this->instance;
     }
     $closureToCall = $this->closureToCall;
     $args = $this->arguments;
     switch (count($args)) {
         case 0:
             return $closureToCall();
         case 1:
             return $closureToCall($args[0]);
         case 2:
             return $closureToCall($args[0], $args[1]);
         case 3:
             return $closureToCall($args[0], $args[1], $args[2]);
         case 4:
             return $closureToCall($args[0], $args[1], $args[2], $args[3]);
         case 5:
             return $closureToCall($args[0], $args[1], $args[2], $args[3], $args[4]);
         default:
             return forward_static_call_array($closureToCall, $args);
     }
 }
 public static function updatePackageSequode($sequode_id, $_model = null)
 {
     $modeler = static::$modeler;
     $_model == null ? forward_static_call_array(array($modeler, 'model'), array()) : forward_static_call_array(array($modeler, 'model'), array($_model));
     $modeler::model()->updateField($sequode_id, 'sequode_id');
     return $modeler::model();
 }
 public static function updateName($name, $_model = null)
 {
     $modeler = static::$modeler;
     $_model == null ? forward_static_call_array(array($modeler, 'model'), array()) : forward_static_call_array(array($modeler, 'model'), array($_model));
     $modeler::model()->updateField(str_replace(" ", "_", $name), 'name');
     return $modeler::model();
 }
Example #19
0
 /**
  * @param string $name
  * @param array $params
  * @return mixed|object
  */
 public function __call($name, $params)
 {
     $query = strpos($name, 'Query');
     $static = strpos($name, 'static');
     if ($static === 0) {
         $property = mb_substr($name, 6);
     } else {
         if ($query !== false) {
             $property = mb_substr($name, 6, -5);
         } else {
             $property = mb_substr($name, 6);
         }
     }
     $property = lcfirst($property) . 'Class';
     if ($static === 0) {
         $method = ArrayHelper::remove($params, '0', 'className');
         return forward_static_call_array([$this->{$property}, $method], $params);
     }
     if ($query) {
         $method = ArrayHelper::remove($params, '0', 'find');
         return forward_static_call_array([$this->{$property}, $method], $params);
     }
     if (isset($this->{$property})) {
         $config = [];
         if (isset($params[0]) && is_array($params[0])) {
             $config = $params[0];
         }
         $config['class'] = $this->{$property};
         return Yii::createObject($config);
     }
     return parent::__call($name, $params);
 }
Example #20
0
 /**
  * Magic method run protected/private static methods.
  *
  * @param string $name The called method name.
  * @param array $arguments Array of arguments.
  */
 public static function __callStatic($name, $arguments)
 {
     $class = get_called_class();
     if (method_exists($class, $name)) {
         return forward_static_call_array([$class, $name], $arguments);
     }
 }
 public static function run()
 {
     $route_class = false;
     $routes_classes = Runtime::model()->routes;
     $route = 'index';
     $request_pieces = self::requestUriPieces();
     if (isset($request_pieces[0]) && trim($request_pieces[0]) == '') {
         foreach ($routes_classes as $routes_class) {
             if (in_array('index', get_class_methods('\\' . $routes_class))) {
                 $parameters = array();
                 unset($request_pieces);
                 forward_static_call_array(array('\\' . $routes_class, 'index'), $parameters);
                 return;
             }
         }
     }
     if (isset($request_pieces[0]) && trim($request_pieces[0]) != '') {
         foreach ($routes_classes as $routes_class) {
             if (isset($request_pieces[0]) && in_array($request_pieces[0], Routes::routes('\\' . $routes_class))) {
                 $route = Routes::route('\\' . $routes_class, trim($request_pieces[0]));
                 array_shift($request_pieces);
                 $parameters = array();
                 if (isset($request_pieces[0])) {
                     $parameters = $request_pieces;
                 }
                 unset($request_pieces);
                 forward_static_call_array(array('\\' . $routes_class, $route), $parameters);
                 return;
             }
         }
     }
     if (isset(Runtime::model()->module)) {
         return forward_static_call_array(array('\\' . Runtime::model()->module, 'run'), array());
     }
 }
Example #22
0
 private static function doCall($type, $type_param, $functionName, $params = array())
 {
     if (Yii::app()->params['isUnitTests'] === true) {
         switch ($type) {
             case 'static':
                 return StubFactory::getStub($type_param . '::' . $functionName);
             case 'instance':
                 return StubFactory::getStub(get_class($type_param) . '->' . $functionName);
             default:
                 throw new InvalidArgumentException('Unknown type of call: ' . $type);
         }
     }
     if (!$params) {
         $params = array();
     } else {
         if (!is_array($params)) {
             $params = array($params);
         }
     }
     switch ($type) {
         case 'static':
             return forward_static_call_array(array($type_param, $functionName), $params);
         case 'instance':
             return call_user_func_array(array($type_param, $functionName), $params);
         default:
             throw new InvalidArgumentException('Unknown type of call: ' . $type);
     }
 }
Example #23
0
 public static function call($route_class, $route, $parameters = null)
 {
     if ($parameters == null) {
         $parameters = array();
     }
     return forward_static_call_array(array($route_class, $route), $parameters);
 }
 public function __call($method, $arg_array = null)
 {
     try {
         if ($this->method) {
             if (method_exists('Pingpp\\' . $this->method, $method)) {
                 $func = 'Pingpp\\' . $this->method . '::' . $method;
                 $ret = forward_static_call_array($func, $arg_array);
                 return $ret;
             }
         } else {
             $class = 'Pingpp\\' . $method;
             if (class_exists($class)) {
                 $this->method = $method;
                 return $this;
             } else {
                 if (method_exists('Pingpp\\Charge', $method)) {
                     $func = 'Pingpp\\Charge::' . $method;
                     $ret = forward_static_call_array($func, $arg_array);
                     return $ret;
                 }
             }
         }
     } catch (Pingpp\Error\Base $e) {
         $this->err = $e;
         return false;
     }
     return null;
 }
 public function staticCallArray($callback, array $params = [])
 {
     if (!is_callable($callback)) {
         throw new InvalidArgumentException('Error', 'callableParameter', '1.($callback)');
     }
     return forward_static_call_array($callback, $params);
 }
 public static function login($json = null)
 {
     $module = static::$module;
     $dialogs = $module::model()->components->dialogs;
     $dialog = forward_static_call_array(array($dialogs, __FUNCTION__), array());
     if (!SessionStore::is($dialog->session_store_key)) {
         return;
     }
     $xhr_cards = $module::model()->xhr->cards;
     $operations_xhr = $module::model()->xhr->operations;
     $operations = $module::model()->operations;
     $modeler = $module::model()->modeler;
     if ($json != null) {
         $input = json_decode(rawurldecode($json));
         if (isset($input->reset)) {
             SessionStore::set($dialog->session_store_key, $dialog->session_store_setup);
             return forward_static_call_array(array($xhr_cards, __FUNCTION__), array());
         }
     }
     $dialog_store = SessionStore::get($dialog->session_store_key);
     $dialog_step = $dialog->steps[$dialog_store->step];
     if (isset($dialog_step->prep) && $dialog_step->prep == true) {
         if (isset($dialog_step->required_members)) {
             foreach ($dialog_step->required_members as $m) {
                 if (!isset($input->{$m})) {
                     return;
                 }
             }
         }
         switch ($dialog_store->step) {
             case 0:
                 if (($modeler::exists(rawurldecode($input->login), 'email') || $modeler::exists(rawurldecode($input->login), 'name')) && \Sequode\Application\Modules\Account\Authority::isActive($modeler::model())) {
                     $dialog_store->prep->user_id = $modeler::model()->id;
                     SessionStore::set($dialog->session_store_key, $dialog_store);
                 } else {
                     $error = 1;
                 }
                 break;
             case 1:
                 if ($modeler::exists($dialog_store->prep->user_id, 'id') && \Sequode\Application\Modules\Account\Authority::isPassword(rawurldecode($input->secret), $modeler::model())) {
                     $_a = array($modeler::model());
                 } else {
                     $error = 2;
                 }
                 break;
         }
     }
     if (isset($dialog_step->operation) && is_array($_a)) {
         if (!forward_static_call_array(array($operations, $dialog_step->operation), $_a)) {
             $error = 3;
         }
     }
     if (!isset($error)) {
         $dialog_store->step++;
         SessionStore::set($dialog->session_store_key, $dialog_store);
         $console_module = ModuleRegistry::model()['Console'];
         return intval($dialog_store->step) == 2 ? forward_static_call_array(array($console_module::model()->routes['http'], 'js'), array(false)) : forward_static_call_array(array($xhr_cards, __FUNCTION__), array());
     }
 }
Example #27
0
 public function __call($name, $arguments)
 {
     if (method_exists('Underscore\\Methods\\ArraysMethods', $name)) {
         return forward_static_call_array(['Underscore\\Types\\Arrays', $name], $arguments);
     } elseif (method_exists('Illuminate\\Support\\Arr', $name)) {
         return forward_static_call_array(['Illuminate\\Support\\Arr', $name], $arguments);
     }
 }
Example #28
0
 /**
  * Returns the *Singleton* instance of this class.
  *
  * @return Singleton The *Singleton* instance.
  */
 public static function i()
 {
     if (func_num_args() === 0) {
         return static::getInstance();
     } else {
         return forward_static_call_array(['static', 'getInstance'], func_get_args());
     }
 }
 public static function logout()
 {
     $module = static::$module;
     $operations = $module::model()->operations;
     forward_static_call_array(array($operations, __FUNCTION__), array());
     $console_module = ModuleRegistry::model()['Console'];
     forward_static_call_array(array($console_module::model()->routes['http'], 'js'), array(false));
 }
Example #30
0
 /**
  * Add one column to the table.
  *
  */
 public function addColumn()
 {
     $model = $this->models->first();
     $new_column = forward_static_call_array([new Column(), 'create'], func_get_args());
     $new_column->setOptionsFromModel($model);
     $this->columns[] =& $new_column;
     return $new_column;
 }