/** * Возвращает объект данного класса, с информацией, полученный по id * * @param type $id * @return \self */ public static function get($id) { $r = self::_get($id); $result = new self(); $result->setParams($r); return $result; }
public static function fromRouteData($route, array $params = array(), array $options = array()) { $internalRoute = new self(); $internalRoute->setRoute($route); $internalRoute->setParams($params); $internalRoute->setOptions($options); return $internalRoute; }
/** * Creates a Dispatcher instance from a class name. * * @param string $className Fully qualified class name. * @param string $action Action name. * @param array $params Parameters. * * @return Dispatcher */ public static function customDispatcher($className, $action, $params) { $dispatcher = new self(); $dispatcher->setClassName($className); $dispatcher->setAction($action); $dispatcher->setParams($params); return $dispatcher; }
/** * @param $source Title * @param $target Title * @param $params array, should include base-source and base-target * @param $performer * @return MoveJob */ public static function newJob( Title $source, Title $target, array $params, /*User*/ $performer ) { $job = new self( $source ); $job->setUser( FuzzyBot::getUser() ); $job->setTarget( $target->getPrefixedText() ); $job->setSummary( wfMsgForContent( 'pt-movepage-logreason', $params['base-source'] ) ); $job->setParams( $params ); $job->setPerformer( $performer ); $job->lock(); return $job; }
/** * @param array $data * @return Request */ public static function fromArray(array $data) { self::validateData($data); $Request = new self($data['method']); if (array_key_exists('params', $data)) { $Request->setParams($data['params']); } if (array_key_exists('id', $data)) { $Request->setId($data['id']); } return $Request; }
/** * @param $source Title * @param $target Title * @param $params array, should include base-source and base-target * @param $performer * @return TranslateMoveJob */ public static function newJob(Title $source, Title $target, array $params, $performer) { $job = new self($source); $job->setUser(FuzzyBot::getUser()); $job->setTarget($target->getPrefixedText()); $summary = wfMessage('pt-movepage-logreason', $params['base-source']); $summary = $summary->inContentLanguage()->text(); $job->setSummary($summary); $job->setParams($params); $job->setPerformer($performer); $job->lock(); return $job; }
/** * @param array $data * * @throws \Elastica\Exception\InvalidException * * @return self */ protected static function _createFromArray(array $data) { if (!isset($data['script_file'])) { throw new InvalidException("\$data['script_file'] is required"); } $scriptFile = new self($data['script_file']); if (isset($data['params'])) { if (!is_array($data['params'])) { throw new InvalidException("\$data['params'] should be array"); } $scriptFile->setParams($data['params']); } return $scriptFile; }
/** * Duplicates a job with similar properties to the original. * * @return NineThousand\Jobqueue\Vendor\Doctrine\Adapter\Job\DoctrineJobAdapter */ public function spawn() { $entity = new JobEntity; $entity->setRetry($this->_jobEntity->getRetry()); $entity->setCooldown($this->_jobEntity->getCooldown()); $entity->setMaxRetries($this->_jobEntity->getMaxRetries()); $entity->setAttempts(0); $entity->setExecutable($this->_jobEntity->getExecutable()); $entity->setType($this->_jobEntity->getType()); $entity->setStatus(null); $entity->setCreateDate(new \DateTime("now")); $entity->setLastRunDate(null); $entity->setActive(1); $entity->setSchedule(null); $entity->setParent($this->_jobEntity->getId()); $this->_em->persist($entity); $this->_em->flush(); //instantiate duplicated job adapter and set params, args, tags $jobAdapter = new self($this->_options, $entity, $this->_em, $this->_logger); if (count($params = $this->getParams())) $jobAdapter->setParams($params); if (count($args = $this->getArgs())) $jobAdapter->setArgs($args); if (count($tags = $this->getTags())) $jobAdapter->setTags($tags); return $jobAdapter; }
/** * Retrieve the next signal from the SW Engine's event queue * * @param array $options * @return Streamwide_Engine_Signal|boolean */ public static function dequeue(array $options = null) { $registry = Streamwide_Engine_Registry::getInstance(); // initialize options to their default values if (null === ($engineProxy = $registry->get(SW_ENGINE_PROXY))) { $engineProxy = new Streamwide_Engine_Proxy(); $registry->set(SW_ENGINE_PROXY, $engineProxy); } $timeout = -1; $savePhpId = true; if (is_array($options)) { if (isset($options['timeout'])) { $timeout = (int) $options['timeout']; } if (isset($options['engineProxy']) && $options['engineProxy'] instanceof Streamwide_Engine_Proxy) { $engineProxy = $options['engineProxy']; $registry->set(SW_ENGINE_PROXY, $engineProxy); } if (isset($options['savePhpId'])) { $savePhpId = (bool) $options['savePhpId']; } } if (false === ($array = $engineProxy->nextEvent($timeout))) { return false; } $name = $array[self::SIG_NAME]; $phpId = $array[self::SIG_PHPID]; $remote = $array[self::SIG_REMOTE]; $params = $array[self::SIG_PARAMS]; if ($savePhpId) { $registry->set(SW_ENGINE_CURRENT_PHPID, $phpId); } $signal = new self($engineProxy); $signal->setName($name); $signal->setPhpId($phpId); $signal->setRemote($remote); $signal->setParams($params); return $signal; }
public static function create($params) { $obj = new self(); $obj->setParams($params); return $obj; }