Queue named constructor.

@param string  $type
@param mixed[] $input

@return \PlanB\DS\Queue\Queue
330251
public static function typed(string $type, iterable $input = []): Queue
    {
        $resolver = Resolver::typed($type);

        return new static($input, $resolver);
    }
1044179
public function flush($type) {
		if (isset($this->cache[$type])) $this->cache[$type]=array();
		return $this;
	}
465159
public function pushAll(iterable $input): QueueInterface
    {
        foreach ($input as $value) {
            $this->push($value);
        }

        return $this;
    }
959223
protected static function init(string $type = 'string', string $key = null, string $name = null)
    {
        $instance = new static();

        $instance->key($key);
        $instance->field['type'] = $type;

        if ($name) $instance->field['name'] = $name;

        return $instance;
    }
133819
function Queue(parameters) {
    parameters = parameters || new composites.Parameters(new Catalog());
    if (!parameters.getParameter('$type')) parameters.setParameter('$type', '/bali/collections/Queue/v1');
    abstractions.Collection.call(this, utilities.types.QUEUE, parameters);

    // the capacity and array are private attributes so methods that use it are
    // defined in the constructor
    var capacity = 1024;  // default capacity
    if (parameters) {
        const value = parameters.getParameter('$capacity', 2);
        if (value) capacity = value.toNumber();
    }
    const array = [];

    this.acceptVisitor = function(visitor) {
        visitor.visitQueue(this);
    };

    this.toArray = function() {
        return array.slice();  // copy the array
    };

    this.getSize = function() {
        return array.length;
    };

    this.addItem = function(item) {
        if (array.length < capacity) {
            item = this.convert(item);
            array.push(item);
            return true;
        }
        throw new utilities.Exception({
            $module: '/bali/collections/Queue',
            $procedure: '$addItem',
            $exception: '$resourceLimit',
            $capacity: capacity,
            $text: '"The queue has reached its maximum capacity."'
        });
    };

    this.removeItem = function() {
        if (array.length > 0) return array.splice(0, 1)[0];  // remove the first item in the array
    };

    this.getHead = function() {
        return array[0];
    };

    this.deleteAll = function() {
        array.splice(0);
    };

    return this;
}
113850
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $queueType = $input->getOption('queue-type');
        $notifyEmail = $input->getOption('notify-email');

        $manager = $this->getManager();

        if ($notifyEmail !== false) {
            $notify = new \Expose\Notify\Email();
            $notify->setToAddress($notifyEmail);
            $manager->setNotify($notify);
        }

        if ($queueType !== false) {
            $queueConnect = $input->getOption('queue-connect');
            if ($queueConnect === false) {
                $output->writeln('<error>Queue connection string not provided</error>');
                return;
            }
            // make the queue object with the right adapter
            $queueClass = '\\Expose\\Queue\\'.ucwords(strtolower($queueType));
            if (!class_exists($queueClass)) {
                $output->writeln('<error>Invalid queue type "'.$queueType.'"</error>');
                return;
            }
            $queue = new $queueClass();

            $adapter = $this->buildAdapter($queueType, $queueConnect, $queue->getDatabase());
            if ($adapter === false) {
                $output->writeln('<error>Invalid connection string</error>');
                return;
            }
            $queue->setAdapter($adapter);

        } else {
            $output->writeln('<error>Queue type not defined</error>');
            return;
        }
        $this->setQueue($queue);

        if ($input->getOption('list') !== false) {
            $output->writeln('<info>Current Queue Items Pending</info>');
            $this->listQueue($manager, $queue);
            return true;
        }

        // by default process the current queue
        $reports = $this->processQueue($output);
        if (count($reports) == 0) {
            return;
        }

        $exportFile = $input->getOption('export-file');
        if ($exportFile !== false) {
            $output->writeln('<info>Outputting results to file '.$exportFile.'</info>');
            file_put_contents(
                $exportFile,
                '['.date('m.d.Y H:i:s').'] '.json_encode($reports),
                FILE_APPEND
            );
        } else {
            echo json_encode($reports);
        }
    }
262749
protected function setType(InputInterface $input)
    {
        $type = TypeTable::query()
            ->setFilter([
                'ID' => $input->getArgument('type'),
            ])
            ->setSelect(['ID'])
            ->exec();

        if ($type->getSelectedRowsCount() <= 0) {
            $this->errors[] = 'Type not found';
        }

        $this->type = $type->fetch()['ID'];
    }
175271
public function createGroup(InputStruct $input)
    {
        $objectStateGroup = $this->objectStateMapper->createObjectStateGroupFromInputStruct($input);
        $this->objectStateGateway->insertObjectStateGroup($objectStateGroup);

        return $objectStateGroup;
    }
41906
public function push($owner, $instance, $type = 'default')
    {
        if ($instance === null) {
            return $this;
        }

        $owner_id = spl_object_id($owner);

        if (!isset($this->_pool[$owner_id][$type])) {
            $queue = new \SplQueue();
            $this->_pool[$owner_id][$type] = $queue;
        } else {
            $queue = $this->_pool[$owner_id][$type];
        }

        $queue->push($instance);

        return $this;
    }
446181
public function addInput(Input $input)
    {
        $reflection = new \ReflectionClass($input);

        $method = 'add'.$reflection->getShortName();

        if (method_exists($this, $method)) {
            $this->$method(...array_values($input->getAttributes()));
        }
    }
828429
public function create($type)
    {
        $typeOptions    = $this->getOption(self::OPTION_MAPPERS);
        $typeOption     = isset($typeOptions[$type]) ? $typeOptions[$type] : $this->throwException();
        $importerString = isset($typeOption[self::OPTION_MAPPERS_IMPORTER]) ? $typeOption[self::OPTION_MAPPERS_IMPORTER] : $this->throwException();
        $importer       = $this->buildService($importerString, ImportServiceInterface::class);

        if (isset($typeOption[self::OPTION_MAPPERS_MAPPER])) {
            $mapperString = $typeOption[self::OPTION_MAPPERS_MAPPER];
            $mapper       = $this->buildService($mapperString);
        } else {
            $mapper = $this->getDefaultMapper();
        }

        $this->propagate($mapper);
        $importer->setMapper($mapper);

        return $importer;
    }
474767
public function with_input( array $input = null ) {
		$this->get_session()->flash_input(
			$this->clean_input( ! is_null( $input ) ? $input : $this->get_request()->input() )
		);

		return $this;
	}
1278680
public function queue($type, JsonArray $metaData = null)
    {
        $taskId = $this->generateId();

        if (null === $metaData) {
            $metaData = new JsonArray();
        }

        $metaData
            ->set(Task::SETTING_ID, $taskId)
            ->set(Task::SETTING_TYPE, $type)
            ->set('status', Task::STATE_PENDING)
            ->set(Task::SETTING_CREATED_AT, date('c'));

        $taskFile = new JsonFile($this->taskIdToFileName($taskId), null);
        $taskFile->setData($metaData->getData());
        $taskFile->save();

        if (!$this->createTaskFromMetaData($taskFile)) {
            unlink($taskFile->getFilename());
            throw new \InvalidArgumentException('Could not create task of type "' . $metaData->get('type') . '"');
        }

        $this->getConfig()->set($taskId, $metaData->getData());

        return $taskId;
    }
614876
public function send($input)
    {
        if (stripos(strrev($input), PHP_EOL) === false) {
            $input = $input . PHP_EOL;
        }

        $this->steps[] = [self::SEND, $input];

        return $this;
    }
302773
public function create($input)
	{
		$mapper = $this->getMapper();
		$admin  = $mapper->getAdmin();

		$model      = $this->getModel();
		$primaryKey = (new $model)->getKeyName();

		$this->setInput($input);

		// Field pre update
		foreach ($mapper->getFields() as $field) {
			$field->preUpdate();
			$input = $this->getInput();

			// Is this a multiple field?
			if ($field->isMultiple()) {
				$value = Value::encode(Config::get('bauhaus::admin.multiple-serializer'), $input[$field->getName()]);
				$this->setInputVariable($field->getName(), $value);
			}

			if ($field->hasSaving()) {
				$saving = $field->getSaving();
				$this->setInputVariable($field->getName(), $saving($input[$field->getName()]));
			}
		}

		// Model before create hook
		if (method_exists($admin, 'beforeCreate')) {
			$admin->beforeCreate($input);
		}

		// Validate
		if (property_exists($model, 'rules')) {
			$validator = Validator::make($this->getInput(), $model::$rules);
			if ($validator->fails()) {
				return $validator;
			}
		}

		// Model create hook
		if (method_exists($admin, 'create')) {
			$model = $admin->create($this->getInput());
		} else {
			$model = $model::create($this->getInput());
		}

		// Set the primary id from the `new` model
		$this->setIdentifier($model->{$primaryKey});

		// Field post update
		foreach ($mapper->getFields() as $field) {
			$field->postUpdate($this->getInput());
		}

		// Model after create hook
		if (method_exists($admin, 'afterCreate')) {
			$result = $admin->afterCreate($this->getInput());

			if ($result instanceof \Illuminate\Http\RedirectResponse) {
				$result->send();
			}
		}

		return $this;
	}
876760
public function updateOrCreate(array $input)
    {
        $this->cache->tags($this->getModel())->flush();
        return $this->repository->updateOrCreate($input);
    }
425123
public function execute(array $input = [])
    {
        $this->input = $input;
        $data = $this->run();

        return new Response($data ?: []);
    }